Lesson 51.3 · 3 of 6 · 4 min read · Reviewed 24 Nov 2026
Graph-based frameworks (LangGraph and similar)
By the end, you can
- Describe graph-based agent frameworks.
- Know their strengths and costs.
The model
[ classify ]
/ \
[ answer FAQ ] [ look up order ] --> [ needs refund? ] --yes--> [ human approval ] --> [ refund ]
\ |no
\______________________________________v
[ reply ]
- Nodes: a model call, a tool call, or plain code.
- Edges: fixed or conditional transitions.
- State: a shared object each node reads and updates.
Strengths
- Explicit control flow: easier to review than a free-running loop.
- Mix of workflowWorkflow: A system where LLM calls and tools follow a path defined in code, rather than chosen by the model. and agentAgent: A system where a model decides its own next steps, calling tools in a loop until the task is done.: fixed paths where you want them, agent loopsAgent loop: The cycle of calling the model, running any tools it requests, returning the results and repeating until it stops. inside nodes where you need flexibility.
- Checkpoints: pause for human input, resumeSession resumption: Continuing an earlier session by reloading its saved history or state. after failures, replay runs.
- Multi-agentMulti-agent system: A design where several agents with different roles or contexts work together on a task. graphs: agents as nodes.
Costs
- Concepts to learn and framework code to maintain.
- Graphs can grow complex; keep them small and well named.
- As with any framework, check what prompts and calls it really makes (51.1).
Use it with Claude through the framework’s Anthropic integration, and make sure features you rely on (caching, thinking, structured outputsStructured outputs: Making a model return data that matches a defined schema, such as JSON with required fields and types.) pass through.
Key points
- Graph frameworks (LangGraph and similar) model an agent as nodes (steps) and edges (transitions) over shared state.
- They make control flow explicit: loops, branches, retries and human-approval steps are drawn into the graph.
- Checkpointing state lets runs pause, resume and be inspected.
- The trade-off is more structure and framework concepts to learn.
Rebuild the refund graph in LangGraph
Express the refund flow from 43.3 as nodes, edges and state in a graph framework, with a pause for approval.
You will have: A small LangGraph script on your machine that pauses before the refund node and resumes after approval.
Steps
- Create a virtual environment and install LangGraph from its official docs (pip install langgraph). No API key is needed: the nodes can be plain functions.
- Define a state with order, refund_due and approved, and write look_up, needs_refund, approve and refund as plain functions.
- Add the edges, with a conditional edge after needs_refund, and compile the graph with an in-memory checkpointer.
- Run it with a thread id, pause before the refund node (the docs call this an interrupt), inspect the saved state, then resume with approval.
- Count the framework concepts you had to learn and note them next to what you gained.
Done when
- The run stops before refund and the saved state shows refund_due: true.
- Resuming with the same thread id runs refund exactly once.
- You have a short note of what the graph made explicit compared with a plain loop.