> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Inject Context • AI Agent SDK

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

# inject\_context

Method

> This is a method of the [**GatewayTraceHook**](https://praison.ai/docs/sdk/reference/praisonaiagents/classes/GatewayTraceHook.md) class in the [**protocols**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/protocols.md) 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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def inject_context(carrier: 'MutableMapping[str, str]') -> None
```

## Parameters

**carrier** `'MutableMapping[str, str]'` *required*

No description available.

## Source

> [card] [View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/gateway/protocols.py#L6806)
>
> `praisonaiagents/gateway/protocols.py` at line 6806

***

## Related Documentation

> [card] [Context Concept](https://praison.ai/docs/docs/concepts/context)

> [card] [Context Management](https://praison.ai/docs/docs/features/context-management)

> [card] [Context Strategies](https://praison.ai/docs/docs/features/context-strategies)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.