datarobot_genai.core.telemetry.agent_identity
agent_identity
Propagates gen_ai.agent.name across a tool-call boundary via OTel Baggage.
A tool-call span (e.g. an MCP tool served by drmcp, possibly over a
network hop) has no attribute of its own for which agent invoked it - trace
parentage doesn't carry span attributes across that boundary. Baggage does,
via auto-instrumented HTTP clients that inject whatever is in the active
context on every outgoing request, so attaching it here needs no explicit
inject/extract call pairs; the receiving side just reads it back out.
attach_agent_name_baggage
Attach agent_name into OTel Baggage on the current context.
Returns the detach token, or None when agent_name is falsy (no
context change made). Callers must pass whatever this returns to
:func:detach_agent_name_baggage when the wrapped scope ends - always,
even when it's None, so a no-op attach is a no-op detach too.
Source code in datarobot_genai/core/telemetry/agent_identity.py
agent_name_baggage
Context-manager form of :func:attach_agent_name_baggage for callers
with a natural with scope around the agent's execution.