LangGraph Python tutorial with RAG and Claude Code
Build stateful LangGraph workflows with routing, RAG and Claude Code approval loops using GPT-4.1 mini and an in-memory checkpointer.
Player not loading? Watch on YouTube
This Python crash course builds a LangGraph workflow that routes requests to chat, knowledge retrieval or code editing. The presenter describes LangGraph as a lower-level orchestration framework within the LangChain ecosystem and recommends some familiarity with LangChain, though it is not a prerequisite.
Setup uses an API key in a .env file and packages installed through uv or pip. The examples call OpenAI's GPT-4.1 mini; they do not demonstrate how to run models locally. A basic start-to-prompt-to-end graph introduces nodes, edges and message state. An in-memory checkpointer and a consistent thread ID then preserve conversation context across invocations.
The larger AI agent uses a Pydantic schema to classify intent and conditional edges to select a branch. Its RAG branch searches an in-memory vector store for three relevant documents using text-embedding-3-small. The presenter also adds NumPy for similarity search.
The coding branch invokes Claude Code through Python subprocess in headless mode. Claude Code must already be installed and configured; that setup is outside the tutorial. An approval node pauses execution, and a revision loop keeps asking until the user approves or denies the request. A final prompt-preparation node includes conversation history so the coding assistant receives context that a raw request would omit. The tutorial also exports the workflow as a Mermaid PNG.