LangGraph Overview
LangGraph is a framework for building stateful, multi-actor applications with LLMs. It represents agent logic as a graph where:- Nodes are processing steps (e.g., plan actions, execute tools)
- Edges define the flow between nodes
- State is a typed dictionary that flows through the graph
Agent State
The agent maintains a typed state that carries information through the graph:Using
TypedDict instead of Pydantic models allows dictionary-style access (state["key"]) which is required by LangGraph, while still providing type hints for IDE support.Graph Structure
The agent graph has the following nodes and edges:Graph Nodes
plan_actions
plan_actions
Plans which tools to execute based on user input.Input:
user_message, conversation_historyOutput: actions, requires_confirmation, discovered_toolsThis node uses meta-tools (discover, schema, invoke) to find and use the right tools without loading all tool schemas upfront. The LLM iteratively discovers tools, checks their schemas, and invokes them.agent/graph/nodes/plan_actions.py
route_execution
route_execution
Determines how to execute the planned actions.Input:
actions, requires_confirmationOutput: execution_modeSets execution_mode to:"confirm"if destructive operations need approval"sequential"if actions have dependencies"parallel"for independent actions
confirm_actions
confirm_actions
Requests user confirmation for destructive operations.Input:
actionsOutput: confirmation_message, pending_confirmationThis node is configured as an interrupt point - the graph pauses here and waits for user input before continuing.agent/graph/graph_builder.py
execute_parallel
execute_parallel
Executes independent actions in parallel using ThreadPoolExecutor.Input:
actionsOutput: resultsagent/graph/nodes/execute_tools.py
execute_sequential
execute_sequential
Executes actions sequentially, respecting dependencies.Input:
actionsOutput: resultsUses topological sort to order actions by their depends_on relationships. Results from earlier actions can be injected into later actions.agent/graph/nodes/execute_tools.py
synthesize_response
synthesize_response
Creates a natural language response for the user.Input:
actions, results, user_messageOutput: final_responseThe LLM synthesizes the tool results into a conversational response that answers the user’s original question.Graph Edges
Edges define transitions between nodes:Checkpointing and Persistence
The graph uses a checkpointer to save state between interactions:- Multi-turn conversations: State persists across messages
- Human-in-the-loop: Graph can pause at interrupt points
- Error recovery: State can be rolled back if needed
Example Execution Flow
Let’s trace a request through the graph:User Input
User: “Delete my meeting with John”State:
{user_message: "Delete my meeting with John", ...}plan_actions Node
LLM uses meta-tools:
discover_tools(categories=["calendar"], actions=["delete"])→ findsdelete_calendar_eventdiscover_tools(categories=["calendar"], actions=["search"])→ findssearch_calendar_eventsinvoke_tool("search_calendar_events", {"query": "John"})→ finds event ID- Marks
delete_calendar_eventfor confirmation
{actions: [{tool: "delete_calendar_event", args: {event_id: "123"}}], requires_confirmation: true, ...}route_execution Node
Checks
requires_confirmation and sets execution_mode to "confirm"State: {execution_mode: "confirm", ...}confirm_actions Node (Interrupt)
Graph pauses and returns to user:“This will delete the calendar event: ‘Meeting with John’ on Tuesday at 2:00 PM. Confirm? (yes/no)”
execute_parallel Node
Executes the delete operation:State:
{results: {a1: {success: true, message: "Event deleted"}}, ...}Meta-Tools Pattern
The graph uses a “meta-tools” pattern to reduce token usage by 96%: Instead of loading all 15+ tool schemas (≈6000 tokens), the agent has access to just 3 meta-tools (≈550 tokens):- discover_tools: Find tools by category/action
- get_tool_schema: Get full schema for a specific tool
- invoke_tool: Execute a tool with parameters
Learn More
See the Tools System page for details on meta-tools implementation
Next Steps
Tools System
Learn how tools are registered, validated, and executed
Agent Flow
See complete examples of agent execution flows