Skip to content

Add gen_ai.agent.invocation.trigger attribute to invoke_agent spans#3614

Open
Krishnachaitanyakc wants to merge 3 commits intoopen-telemetry:mainfrom
Krishnachaitanyakc:agent-invocation-trigger
Open

Add gen_ai.agent.invocation.trigger attribute to invoke_agent spans#3614
Krishnachaitanyakc wants to merge 3 commits intoopen-telemetry:mainfrom
Krishnachaitanyakc:agent-invocation-trigger

Conversation

@Krishnachaitanyakc
Copy link
Copy Markdown

Partially addresses #1961, #2664

Problem

All invoke_agent spans currently look identical regardless of who triggered them.
An operator debugging a multi-agent trace cannot distinguish user-initiated from
agent-delegated invocations without manually walking the span tree.

Before

invoke_agent "Math Tutor"     ← who called this?
  invoke_agent "Calculator"   ← who called this?

After

invoke_agent "Math Tutor"     gen_ai.agent.invocation.trigger=direct
  invoke_agent "Calculator"   gen_ai.agent.invocation.trigger=agent

Operators can now query gen_ai.agent.invocation.trigger = "agent" to find all
delegation-triggered invocations, enabling cost attribution, blast radius analysis,
and debugging without tree-walking.

Why not derive from parent-child?

Parent-child shows temporal containment, not semantic intent. When invoke_agent B
is nested under invoke_agent A, you know B ran during A's execution, but not
whether A deliberately delegated to B or B was invoked for an unrelated reason
within A's scope. This attribute makes intent explicit.

Cross-provider evidence

Framework Trigger detection Signal
CrewAI Task.delegate() with coworker parameter source
AutoGen GroupChatManager speaker selection source
OpenAI Agents SDK Handoff objects with target agent source
Google ADK transfer_to_agent() tool call source
LangGraph send() / conditional edges to agent nodes source

Changes

  • registry.yaml: Add gen_ai.agent.invocation.trigger enum (direct, agent)
  • spans.yaml: Add ref to attributes.gen_ai.invoke_agent.common (applies to both CLIENT and INTERNAL spans)
  • docs: Updated generated agent span docs and registry docs
  • changelog: Added

Design decisions

  • 2 values, not 3: Dropped orchestrator — the agent/orchestrator distinction is not reliably auto-instrumentable and collapses in practice.
  • direct not user: direct is semantically neutral — covers user requests, app logic, cron jobs, and non-agent orchestrators without implying a human initiated it.
  • Placed in common attributes: Applies to both CLIENT and INTERNAL invoke_agent spans via attributes.gen_ai.invoke_agent.common, matching the PR Split invoke_agent into separate client and internal spans, and split attributes from inference hierarchy #3514 architecture.
  • recommended: if known: Instrumentors populate when the framework exposes delegation signals, not forced when trigger is ambiguous.

Adds a new enum attribute to distinguish directly-invoked from
agent-delegated invocations on both CLIENT and INTERNAL invoke_agent
spans. Values: direct (user/app/system trigger) and agent (delegated
by another GenAI agent).

Partially addresses open-telemetry#1961, open-telemetry#2664.
@github-actions github-actions bot added the enhancement New feature or request label Apr 13, 2026
@Krishnachaitanyakc Krishnachaitanyakc marked this pull request as ready for review April 13, 2026 21:43
@Krishnachaitanyakc Krishnachaitanyakc requested review from a team as code owners April 13, 2026 21:44
@Krishnachaitanyakc Krishnachaitanyakc marked this pull request as draft April 14, 2026 18:41
Run `make registry-generation` and `make table-generation` to
update generated docs after adding gen_ai.agent.invocation.trigger.
@Krishnachaitanyakc Krishnachaitanyakc marked this pull request as ready for review April 14, 2026 21:52
Resolve merge conflicts in autogenerated docs, keeping
gen_ai.agent.invocation.trigger attribute with correct footnote
numbering and adopting upstream's gen_ai.tool.definitions schema
reference changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant