Inject Context • AI Agent SDK

inject_context: Write the active span context into “carrier“ as W3C headers.

inject_context

Method

</div>

This is a method of the GatewayTraceHook class in the protocols module.

Write the active span context into `carrier` as W3C headers.

Called at an egress boundary (LLM / MCP / HTTP-tool request) so the downstream service’s spans nest under the current agent turn. A no-op when no exporter is attached, leaving `carrier` untouched.

Signature

python
def inject_context(carrier: 'MutableMapping[str, str]') -> None

Parameters

ParamField 'MutableMapping[str, str]'

No description available.

Source

View on GitHub

praisonaiagents/gateway/protocols.py at line 6806


Related Documentation