The idea
LangGraph models an agent as a state machine. You define a typed state object, nodes (functions that read and update the state) and edges (which node runs next, possibly chosen by a condition). Loops are just edges that point backwards.
This makes control flow explicit: you can see exactly where the model decides, where tools run and where a human approves. Built-in checkpointing saves the state after every node, enabling pause, resume, time travel and human-in-the-loop.
It suits workflows with clear stages and some agentic parts. For a plain tool loop, it is more structure than you need.
Many production agent systems use LangGraph or a similar graph runtime because explicit state and checkpoints make them debuggable.
Picture it
Words to know
- StateGraphThe graph object holding nodes, edges and state schema.
- Conditional edgeAn edge whose target depends on the state.
Try it without code
Draw your agent as a graph
- Take an agent you built.
- Draw each step as a box and each decision as a diamond.
- Mark where state is saved.
Use it in code
A prebuilt ReAct agent in LangGraph with one tool and memory checkpointing.
# pip install langgraph langchain-anthropic
from langgraph.prebuilt import create_react_agent
from langgraph.checkpoint.memory import MemorySaver
from langchain_anthropic import ChatAnthropic
def get_weather(city: str) -> str:
"""Get the current weather for a city."""
return f"11C and rain in {city}"
agent = create_react_agent(ChatAnthropic(model="claude-sonnet-5-5"), [get_weather],
checkpointer=MemorySaver())
cfg = {"configurable": {"thread_id": "demo-1"}}
out = agent.invoke({"messages": [("user", "Weather in Dublin?")]}, cfg)
print(out["messages"][-1].content)
out = agent.invoke({"messages": [("user", "And should I cycle?")]}, cfg) # remembers thread
print(out["messages"][-1].content)Rebuild your research agent as a LangGraph StateGraph with explicit plan, search and write nodes.
Common mistakes
- Using a graph framework before you understand the plain loop.
- Putting huge objects in state that is checkpointed every step.