LangGraph Integration
Pass ZespanCallbackHandler to your graph run. Each node becomes an agent_step span, and the model and tool calls inside it are named after the node or subgraph that made them, all in one trace per run.
LangGraph is a library from the LangChain team for building agents as graphs of nodes, including multi-agent setups such as a supervisor that hands work to specialist subgraphs.
Getting Started
Install the SDK
Install zespan alongside your LangChain and LangGraph packages. LangGraph uses the same ZespanCallbackHandler as LangChain, in Python and TypeScript.
pip install zespan langchain-core langchain-openaiPass the handler to your graph run
Create ZespanCallbackHandler and pass it in the callbacks config when you invoke your compiled graph. Model calls, tools, retrievers and nodes of the run are one trace, with no extra wrapper.
import zespan
from zespan.integrations.langchain_handler import ZespanCallbackHandler
zespan.init(api_key="zsp_your_api_key_here")
handler = ZespanCallbackHandler()
# graph is your compiled LangGraph graph
result = graph.invoke(
inputs,
config={"callbacks": [handler]},
)Add guardrails (optional)
Pass guardrail options to the handler for pre and post checks on model calls. A block raises GuardrailBlockedError. A LangGraph retry policy treats a block like any other error, so exclude it from retries.
handler = ZespanCallbackHandler(guardrails={"pre": True, "post": True})Read the run in Zespan
Open the trace. Each node run is an agent_step span with its superstep and node name, and a node that raised carries stop reason error.
What's captured automatically
- Node steps: each node run as an agent_step span, with the superstep and the node name as its route
- Agent names from your graph: lc_agent_name metadata, then the subgraph, then the node name
- Generic node names such as agent, tools and call_model are skipped, so supervisor specialists show by name
- Hand-offs on the model span: tools_used lists calls such as transfer_to_research_expert
- Calls made inside a tool join the tool's span and the run's trace
- Retriever spans with content-free metadata: returned count, doc ids, hashes and scores
FAQ
Is there a separate LangGraph package?
No. LangGraph uses ZespanCallbackHandler from the LangChain integration, in Python and TypeScript. Node steps and agent names are recorded by the same handler.
How are agents named in a supervisor graph?
A node or subgraph names the agent of the model and tool calls inside it: lc_agent_name in the run's metadata first, then the first part of the checkpoint namespace, then the node name. A supervisor with research_expert and billing nodes shows both by name.
Will model calls be recorded twice if I also use auto-patching?
No. A model call the LangChain and LangGraph integration already records inside the run is recorded once, by the integration, not again by patch_openai() or patch_anthropic().
Start free — 50K traces a month, no card needed
LangGraph integration works on all plans including the free tier.

