diff --git a/develop-docs/sdk/telemetry/traces/modules/ai-agents.mdx b/develop-docs/sdk/telemetry/traces/modules/ai-agents.mdx index 7ba92aabbd9cd..af92d7395c8ee 100644 --- a/develop-docs/sdk/telemetry/traces/modules/ai-agents.mdx +++ b/develop-docs/sdk/telemetry/traces/modules/ai-agents.mdx @@ -20,6 +20,57 @@ Sentry Conventions is the single source of truth. + +## Span Relationships + +An agent invocation span has tool execution and chat span children, but chat spans need not have an agent invocation parent (not all chat requests are triggered by an agent). +Agents can have other children such as extraction, decision and memory spans, depending on what's considered part of an agent execution in a given application. +Automatic instrumentation considers an agent execution to be one run of the agent as represented by the supported library. + +All span types can be children of a tool execution span because tools can be arbitrary functions (including starting subagents and performing handoffs). +Chat, extraction and decision spans are basic building blocks and should not have GenAI spans as children. + +Valid examples: + +### Agent execution with extraction, decision and memory children + +``` +gen_ai.invoke_agent +├── gen_ai.chat +├── gen_ai.memory +├── gen_ai.extraction +├── gen_ai.chat +├── gen_ai.execute_tool +├── gen_ai.chat +└── gen_ai.decide +``` + +### Chat, memory, decision, and extraction spans outside of an agent execution + +``` +gen_ai.chat +gen_ai.extraction +gen_ai.invoke_agent +├── gen_ai.chat +├── gen_ai.execute_tool +└── gen_ai.chat +gen_ai.decide +gen_ai.memory +``` + +### Subagent + +``` +gen_ai.invoke_agent +├── gen_ai.chat +├── gen_ai.execute_tool +│ └── gen_ai.invoke_agent +│ ├── gen_ai.chat +│ ├── gen_ai.execute_tool +│ └── gen_ai.chat +└── gen_ai.chat +``` + ## Invoke Agent Span Describes AI agent invocation.