Skip to main content
Available for: Python and TypeScript.
Zespan provides first-class tracing for Google’s Agent Development Kit (ADK). Every model call, tool invocation, and agent-to-agent delegation in your ADK workflow is captured as a linked span — without modifying your agent definitions.

TypeScript

Installation

Four integration patterns

Choose the integration pattern that fits your setup:
instrumentADK wraps both your coordinator agent and its runner in a single call. Use this when building production ADK applications.

wrapADKRunner — runner-level wrapping

Wraps InMemoryRunner.runEphemeral() and Runner.run() by intercepting the ADK event stream. Emits one span per agent author turn, one span per tool call, and handoff spans on delegation.
wrapADKRunner options:
string
required
Display name for the root agent span in Zespan.
string
default:"coordinator"
Role hint for the agent registry. Use "coordinator" for orchestrators and "specialist" for sub-agents.
string
The model name used by the root agent. Shown in the trace detail panel.
string
Associates all spans from this run with a session in the Sessions view.

ZespanADKCallbackHandler — native ADK callbacks

Uses ADK’s built-in callback system (beforeAgentCallback, afterModelCallback, etc.). Create one handler instance and spread .callbacks into your LlmAgent config. Captures agent spans, LLM spans with full token counts, and tool call spans.
For multi-agent systems, use the same handler instance across all agents so spans share the same trace:
ZespanADKCallbackHandler is also exported as ADKCallbackHandler for shorter imports:

wrapADKAgent — agent-level wrapping

Wraps agent.run() directly. Best for unit tests and simple scripts. Recursively wraps subAgents by default.

What gets captured

All three wrappers capture the same data from the ADK event stream:

Python

Installation

Three integration patterns


ZespanADKCallbackHandler — native ADK callbacks

Uses ADK’s built-in callback system. Create one handler and spread .callbacks into each LlmAgent constructor. Captures agent spans, LLM spans with full token counts, and tool spans. ADK Python is async — run agents with InMemoryRunner inside asyncio.run(). Single agent:
Multi-agent system: Use the same handler instance across all agents — ADK shares the same invocation_id across coordinator and sub-agents, so all spans are automatically linked under one trace.
Tool functions are plain Python functions with type hints and docstrings — ADK auto-generates the function declarations. Return dict or any JSON-serializable value.

ZespanADKTracer — attach to an existing agent

Pass your ADK agent to ZespanADKTracer after creating it. The tracer intercepts agent.run to capture every model call, tool invocation, and agent session as hierarchical spans.

wrap_adk_agent — callback-handler style

wrap_adk_agent is the functional equivalent: it attaches tracing and returns the same agent. Use this when you want a one-liner or are composing agents inline.
Both ZespanADKTracer and wrap_adk_agent accept an optional guardrails argument:

Multi-agent systems

Attach ZespanADKTracer (or call wrap_adk_agent) after the agent is fully configured. Attaching before sub_agents are set means sub-agent spans won’t be linked correctly.

How multi-agent traces look in the dashboard

A coordinator + specialist ADK run produces a trace like this:
Each agent’s total token cost is shown separately in the agent registry view, which also maps the coordinator-specialist hierarchy visually.
Multi-agent trace visualization in Zespan showing coordinator and specialist agent spans

Session and user context

To associate ADK traces with a user session for the Sessions dashboard view, set sessionId and userId in the wrapper options (TypeScript) or via with_zespan_context (Python):