LumiqtraceCallbackHandler integrates with LangChain’s callback system to automatically capture every LLM call, tool invocation, chain step, and retrieval operation as linked spans in Zespan. You pass it once and it instruments the entire execution graph — no changes to your chain or agent logic are needed.
How it works
LangChain calls lifecycle methods on every registeredBaseCallbackHandler at each stage of execution. The Zespan handler subscribes to:
| LangChain event | What Zespan captures |
|---|---|
handleLLMStart / handleLLMEnd | Model, provider, latency, tokens, cost, finish reason |
handleChainStart / handleChainEnd | Chain type, input/output, duration |
handleToolStart / handleToolEnd | Tool name, input args, output, duration |
handleRetrieverStart / handleRetrieverEnd | Query, retrieved document count, duration |
handleAgentAction | Tool selected, reasoning, input |
trace_id so you see the entire chain as a single flame graph in the Traces view.
TypeScript
Installation
Basic usage
Chains
Pass the handler toRunnableSequence or any chain using the config argument:
Agents and tools
The handler captures the full agent loop: plan → tool call → observation → next plan. Each iteration appears as linked spans.RAG with retriever tracing
Python
Installation
Basic usage
Chains
Agents
How traces look in the dashboard
A LangChain agent run produces a trace like this in the flame graph:Guardrails with LangChain
Pass guardrail options toLumiqtraceCallbackHandler to enable pre/post content checks on LLM calls made by the chain:

