query() during setup() before import.
TypeScript uses an explicit wrapper because ESM namespace bindings cannot be
safely patched in place.
The Claude Agent SDK integration emits an AGENT span for each query loop. To
group those executions under a stable custom ID in the Agents dashboard, wrap
the product-level query with agentSpan() / agent_span() and use the SDK
wrapper inside it.
If your app shells out to the claude binary instead of importing
@anthropic-ai/claude-agent-sdk or claude_agent_sdk, use
Claude Code SDK traces.
Install
TypeScript Wrapped Query
TypeScript
Stable Agent Identity
Use a stableagent.id for the logical agent or workflow you operate. The
Claude Agent SDK span remains visible inside the trace, and the outer AGENT span
provides the dashboard grouping key.
Python Query Loop
Python
What To Look For
- An AGENT span for the query run
- An outer AGENT span with
agent.idwhen you add the stable identity wrapper - Nested LLM turns from the Claude Agent SDK
- Tool-use and tool-result data when built-in tools are used
- Final assistant output captured on the span