# How should an instance preserve trace-parent continuity when a federated agent handoff crosses a trust boundary that strips the W3C traceparent header? **Date of Record:** 2026 November 30 **Scope:** Applies to multi-instance agent systems where an initiating agent (the "origin") delegates a sub-task to a peer or auditor agent operated by a different trust domain, and the handoff is instrumented with W3C Trace Context (`traceparent`/`tracestate`) plus OpenTelemetry GenAI semantic-convention span links. Does not apply to intra-domain calls where a single collector owns the propagation channel, nor to purely synchronous single-agent tool calls where the parent span is never serialized across a process boundary. ## Core Distinction The distinction that matters here is between **trace continuation** and **causal linkage**. W3C Trace Context is a *continuation* protocol: the child span inherits `trace_id` and adopts the caller's `span_id` as its `parent_span_id`, producing one unbroken tree with a single root. Span links are a *causal association* mechanism: a span records `links[]` entries pointing at other spans without adopting them as parents, producing a DAG-forest rather than a tree. Federation boundaries routinely break continuation because the `traceparent` header is a trust-bearing artifact. A receiving domain that does not trust the caller's `trace_id` (it can be forged, it can collide, it can encode a caller's internal topology) will legitimately strip or rewrite `traceparent` at its ingress gateway — this is correct security hygiene, not a bug. The non-obvious failure is that most agent handoff code treats the loss of `traceparent` as "start a fresh trace" and *also* drops the span link metadata, because the two were bundled into a single propagation concern. The result is a sub-task that executes correctly but is causally orphaned: its spans exist, its GenAI attributes (`gen_ai.operation.name`, `gen_ai.usage.input_tokens`, `gen_ai.request.model`) are intact, but no auditor can reconstruct which origin reasoning step authorized it. The invariant that must hold across the boundary is: **when continuation is refused, causal linkage must be preserved by a side channel that does not require the receiver to trust the caller's trace identity.** Continuation and linkage are separable; the bug is coupling them. ## What Was Observed An origin agent (`agent-origin`, domain A) is mid-task in a multi-step plan. At step 4 it must delegate a retrieval-and-summarize sub-task to `agent-peer` in domain B. The handoff is an A2A `tasks/send` JSON-RPC call. Domain A's OTel SDK injects `traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01` into the outbound HTTP headers. Domain B's ingress gateway runs a header allowlist that does not include `traceparent` (it is not in the CORS-safelisted set and the gateway was configured before trace context was adopted). The header is silently dropped. `agent-peer` receives the request, finds no `traceparent`, and — per its SDK's default `ALWAYS_ON` propagator with no parent — mints a **new root**: `trace_id=7d1a...`, root span `agent.peer.task`. It executes the sub-task across three tool calls, each a child of the new root. It returns the result. `agent-origin` records the response, continues its plan to step 5, and closes its own trace. Two days later an auditor investigating a bad decision at origin step 5 queries the trace backend for `trace_id=4bf92f35...`. They see origin steps 1–4 and the *outbound* `a2a.send` client span, which has no children. The peer's work — including the tool call that returned the stale document that caused the bad decision — lives in an entirely disconnected trace `7d1a...`. Nothing in the origin trace references it. The `tracestate` header, which carried a vendor-specific `origin_step=4` entry, was also stripped, so even a manual `tracestate`-based join fails. The peer's spans *did* carry a `links[]` entry — but only because a developer had manually added `Link(context=extracted_context)` inside the handler, and that `extracted_context` was `None` because extraction had already failed at the gateway. The link was written as an empty list and serialized as absent. The instrumentation "succeeded" and reported no error. ## Condition of Validity The continuation/linkage separation is only sound under three conditions, and each is independently checkable at the boundary: 1. **The linkage token must be carried in a channel the receiver's allowlist already admits.** In practice this means a structured field inside the JSON-RPC `params.metadata` object or an A2A `message.metadata` key — application-layer payload, not transport header. The gateway that strips `traceparent` does not strip the body. The token is `{trace_id, span_id, sampled, origin_domain, handoff_nonce}` — everything needed to *reconstruct* a link, nothing that asserts parentage. 2. **The receiver must be able to distinguish "no parent because I am a root" from "no parent because continuation was refused."** These are different states and must produce different span shapes. A refused continuation yields a span with `parent_span_id = None` *and* a non-empty `links[]`. A genuine root yields `parent_span_id = None` and empty `links[]`. Collapsing them is the defect. 3. **The link must survive the return path symmetrically.** When `agent-peer` returns its result, `agent-origin`'s response-handling span must link to the peer's root span (whose ID it learns from the response metadata). Otherwise the DAG is one-directional and the auditor can walk origin→peer but not peer→origin, which is exactly the direction needed when the *peer* is the one under investigation. If any condition fails, the system is in a state where sub-task execution is correct but audit reconstruction is impossible, and — critically — the failure is silent because every individual span is well-formed. ## Decision Boundary The boundary is: **at ingress, on encountering a request with no valid `traceparent`, does the receiver have a linkage token in the application payload?** - If **yes**: start a new root span (continuation refused, correctly), attach `links[]` to the reconstructed origin span context, set `span.kind = SERVER`, and emit an attribute `trace.continuation = "refused"` so the topology is explicit. Proceed. - If **no**: this is an unlinked federated handoff. The receiver must **not** silently mint a root and proceed as if all is well. It must either reject the handoff (fail closed) or proceed with a span attribute `trace.linkage = "absent"` that downstream policy can quarantine. The choice between fail-closed and quarantine is a policy decision, but *silent* minting is never correct. The subtle part of the boundary: a receiver cannot tell from the request alone whether the origin *intended* to send a link. A pre-instrumentation origin sends no metadata key at all; a post-instrumentation origin whose metadata serialization dropped the key sends an empty object. Both look like "no token." The discriminator must be a **capability declaration** in the A2A agent card (`capabilities.extensions[].uri = "…/trace-linkage/v1"`). If the peer's card declares the extension and the request lacks the token, that is a *violation* and must raise. If the card does not declare it, absence is expected and the receiver proceeds with `trace.linkage = "unsupported"`. Without this, you cannot distinguish a stripped token from an un-instrumented caller, and you will either over-reject or under-detect. ## Operational Effect With the invariant enforced, the auditor's query changes from "search two disconnected traces and hope" to a single DAG traversal: from the origin root, follow `links[]` to the peer root, follow the peer's child spans to the offending tool call. Mean time to causal root cause drops from hours of manual correlation to one query. The cost is a small amount of application-layer metadata per handoff (sub-kilobyte) and the requirement that every federated peer's agent card declare the linkage extension — which is a one-time negotiation, cached, and cheap. The failure mode this prevents is not data loss; it is **audit blindness under correct execution**. The sub-task ran, the tokens were billed, the result was used — every span is valid — and yet the causal chain is unrecoverable. That is the worst shape of agent failure: silent, well-formed, and invisible until an investigation that depends on the very link that was dropped. ```python from dataclasses import dataclass from typing import Optional class TraceLinkageError(RuntimeError): """Raised when a federated handoff cannot establish causal linkage.""" @dataclass class HandoffEnvelope: traceparent: Optional[str] # transport header, may be stripped linkage_token: Optional[dict] # application-layer metadata peer_declares_linkage_ext: bool # from agent card def establish_peer_span(envelope: HandoffEnvelope) -> dict: """Decide the peer's span shape at a federation ingress. Continuation (traceparent) and linkage (metadata token) are treated as independent concerns. Refused continuation MUST still yield a link. """ has_continuation = envelope.traceparent is not None has_linkage = envelope.linkage_token is not None if has_continuation: # Trusting domain: adopt as parent, no link needed. return {"parent": envelope.traceparent, "links": [], "continuation": "accepted"} # Continuation refused or absent. Now the linkage token decides. if has_linkage: token = envelope.linkage_token required = {"trace_id", "span_id", "origin_domain", "handoff_nonce"} missing = required - token.keys() if missing: raise TraceLinkageError( f"malformed linkage token, missing {sorted(missing)}" ) return { "parent": None, "links": [{ "trace_id": token["trace_id"], "span_id": token["span_id"], "attributes": {"origin_domain": token["origin_domain"]}, }], "continuation": "refused", } # No continuation AND no linkage token. Distinguish expected from violation. if envelope.peer_declares_linkage_ext: # Peer advertises the extension but sent no token: token was stripped # or serialization dropped it. This is a contract violation. raise TraceLinkageError( "peer declares trace-linkage/v1 but handoff carried no linkage token; " "continuation refused and causal chain would be orphaned" ) # Peer never claimed support: absence is expected, quarantine the span. return {"parent": None, "links": [], "continuation": "unsupported"} ```