LangGraph Crash Course - Agent Workflows in Python

NeuralNineAbout 3 min readMay 30, 2026Watch original
THE SUMMARYAI-generated

Key Concepts

  • LangGraph: A library for building stateful, multi-actor applications with LLMs by modeling processes as graphs.
  • Agent Orchestration: The process of managing complex workflows where LLMs act as agents to perform tasks.
  • State Graph: The core structure in LangGraph that manages the flow of data (state) between nodes.
  • Nodes & Edges: Nodes represent functions (tasks), and edges define the flow between them. Conditional edges allow for dynamic routing based on state.
  • Human-in-the-Loop (HITL): A mechanism to pause execution and wait for user approval or input before proceeding.
  • Persistence (Checkpointer): Using memory (e.g., MemorySaver) to maintain conversation context across multiple graph invocations.
  • Structured Output: Using Pydantic models to force LLMs to return data in a specific format (e.g., for intent classification).
  • RAG (Retrieval-Augmented Generation): A technique to provide LLMs with external data from a vector store.

1. LangGraph vs. LangChain

  • LangChain: A high-level toolkit for building LLM wrappers and simple applications.
  • LangGraph: A lower-level, more detailed framework designed for complex, durable, and cyclic agentic workflows.
  • Recommendation: It is beneficial to understand LangChain and basic agent concepts before diving into LangGraph.

2. Core Framework & Setup

  • Environment: Use python-dotenv to manage API keys (e.g., OpenAI).
  • State Management: Define a custom state using TypedDict and Annotated (with add_messages function) to ensure that messages are appended to the history rather than overwritten.
  • Graph Compilation: Use StateGraph to build the workflow and .compile() to create the executable graph instance.

3. Step-by-Step Workflow Implementation

The video demonstrates building a multi-intent agent with the following flow:

  1. Start Node: Receives user input.
  2. Classifier Node: Uses an LLM with structured output (Pydantic) to categorize the intent as chat, knowledge, or code.
  3. Conditional Routing: Uses add_conditional_edge to direct the flow based on the classified intent.
  4. Task Nodes:
    • Chat: Simple conversational response.
    • RAG: Performs a similarity search in an InMemoryVectorStore using text-embedding-3-small and answers based on retrieved context.
    • Coding: Executes claude-code in headless mode via subprocess to modify files in a workspace.
  5. Human-in-the-Loop (HITL):
    • Introduces an interrupt point before the coding agent executes.
    • The user can approve, deny, or revise the request.
    • If revised, the graph loops back to a "Prepare Coding Request" node to refine the prompt using conversation history.

4. Key Technical Details

  • Persistence: By passing a config object with a thread_id (using uuid), the graph maintains context across multiple graph.invoke() calls.
  • Subprocess Integration: Used to run external CLI tools (like claude-code) within the agentic workflow.
  • Visualization: graph.get_graph().draw_mermaid_png() is used to export a visual representation of the workflow, which is essential for debugging complex loops.

5. Notable Quotes

  • "LangGraph is focused on agent orchestration, building complex workflows, and modeling processes as graphs."
  • "Every process that we're going to build with LangGraph is a graph. We start at a node called the starting node and we end at a node called the end node."

6. Synthesis/Conclusion

LangGraph provides a robust, low-level framework for building sophisticated AI agents that require state management, conditional logic, and human oversight. By modeling applications as graphs, developers can create durable, multi-step processes that handle complex tasks like RAG and autonomous coding while maintaining full control over the execution flow and user interaction points. The combination of structured output, persistence, and human-in-the-loop interrupts makes LangGraph a powerful tool for production-grade agentic systems.

AI summaries can miss context or contain errors. Check important details against the original video.

Go a little deeper.

Have a question about this video? Load its transcript to open the video chat.