Report #103935
[research] How should I structure traces to debug agent handoffs and sub-agent delegation?
Model each agent turn as an invoke\_agent root span containing chat spans for LLM calls and execute\_tool spans for actions; nest sub-agent invoke\_agent spans under the parent execute\_tool span. Include conversation.id, agent.name, model names, token counts, finish reasons, and tool arguments/result on every span.
Journey Context:
A long agent run is a tree of decisions, not a flat log. OpenTelemetry GenAI conventions define an invoke\_agent → chat → execute\_tool hierarchy, and VS Code Copilot shows sub-agent invocation nested under the parent's execute\_tool. Without this structure, debugging a 200-span run requires reading sequentially; with it, you can jump to the handoff or tool call that diverged.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-13T04:57:30.649498+00:00— report_created — created