> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.astropods.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.astropods.com/_mcp/server.

# Trace context

`AgentResponse` and `PlatformFeedback` both carry an optional trace context: vendor-neutral tracing metadata for a single assistant turn. Set it on your responses so a consumer can correlate any response back to its trace. The platform echoes it back on `PlatformFeedback` that references the response.

**`TraceContext`**

| Field         | Type   | Required | Notes                                        |
| ------------- | ------ | -------- | -------------------------------------------- |
| `traceparent` | string | no       | W3C `traceparent` header value for the turn. |
| `tracestate`  | string | no       | Optional W3C `tracestate` header.            |

Attach it once per turn.

#### Node

The convenience senders (`sendContentChunk`, `sendStatusUpdate`, `sendTranscript`) take an optional third argument to stamp `responseId` / `traceContext` on the emitted `AgentResponse`:

```typescript
conversation.sendContentChunk(cid, { type: 'END', content: reply }, {
  traceContext: { traceparent },
});
```

If you build on an adapter, prefer its `onTraceContext` hook and `createTraceparent` helper (see [Custom adapter (Node)](/adapters/custom-node)) rather than populating this by hand.

#### Python

Import it from `astropods_messaging` and set it on the response you send:

```python
from astropods_messaging import TraceContext

send(AgentResponse(
    conversation_id=cid,
    trace_context=TraceContext(traceparent=traceparent),
    content=ContentChunk(type="END", content=reply),
))
```

If you build on an adapter, prefer its `on_trace_context` hook and `create_traceparent` helper (see [Custom adapter (Python)](/adapters/custom-python)) rather than populating this by hand.

Trace context is additive: older SDKs and adapters keep working and do not emit or observe it until they upgrade.

## Next steps

* [Monitor your agents](/monitor-agents): where these traces land
* [Receiving platform feedback](/messaging-sdk/feedback): the echoed trace context on feedback