How should an instance reconcile a split trace context when an MCP-to-A2A bridge rewrites the caller identity mid-invocation
**Date of Record:** 2026 December 1 **Scope:** Applies to gateway processes that terminate an MCP session on one side and originate an A2A task on the other, performing identity translation (MCP principal → A2A agent ID / OAuth2 subject) and propagating a W3C `traceparent` plus agent-specific baggage across the boundary. Does not apply to homogeneous MCP↔MCP or A2A↔A2A hops where the identity token is passed through unmodified, nor to stateless request/response proxies that hold no per-invocation state.
Core Distinction
The failure is not "trace IDs get lost." It is that the bridge *rewrites* the identity that the trace's baggage attributes are keyed on, and the two sides of the bridge disagree about which identity is authoritative for parent-child linkage. An MCP caller arrives with a `traceparent` and baggage containing `mcp.principal=<opaque-handle>`. The gateway translates that handle into an A2A `agent_id` and an OAuth2 `sub`, then re-emits the span. If the gateway preserves the inbound `traceparent` verbatim but rewrites the baggage principal, the downstream A2A agent's span inherits a parent whose `mcp.principal` attribute no longer matches the `agent_id` on the child span. The trace is *structurally continuous* (same trace ID, valid parent span ID) but *semantically discontinuous* (the identity chain has a seam). Auditors replaying the trace to answer "who authorized this tool call" see two identities on one lineage and cannot determine which one the downstream tool actually executed under.
The boundary invariant that must hold: **for every span, the identity attributes on the span must be derivable from the identity attributes of its parent span plus a recorded translation event.** When the gateway rewrites identity without emitting a translation span, the invariant is violated even though the trace looks healthy.
What Was Observed
A three-hop invocation: MCP client → bridge gateway → A2A orchestrator → A2A worker (which called a state-mutating tool). The `traceparent` propagated correctly end-to-end; `trace_id` was identical on all four spans. But on replay, the A2A worker's span carried `agent_id=worker-7` and inherited baggage `mcp.principal=anon-3f9a`, while the orchestrator's span carried `agent_id=orch-2` and baggage `mcp.principal=anon-3f9a`, and the gateway's span carried `mcp.principal=anon-3f9a` but *no* `agent_id` (the gateway is not an A2A agent). The OAuth2 `sub` used for the actual authorization decision at the worker was `user:alice@corp`, which appeared nowhere in the baggage. The gateway had translated `anon-3f9a → user:alice@corp` internally to mint the A2A token, then dropped the mapping from the trace. The trace was continuous; the authorization provenance was not.
The concrete trigger: the gateway's identity-translation step ran in a code path that emitted the outbound A2A span *before* the token exchange completed, so the span was created with the inbound baggage and the translated `sub` was attached only to the HTTP headers, not to the span attributes. Under load (translation latency > span-creation ordering), this reordered deterministically. Under low load the `sub` occasionally landed on the span, which is why the defect was invisible in dev.
Condition of Validity
The continuity invariant holds only when all of the following are true at the bridge:
- The gateway emits an explicit **translation span** (child of the inbound MCP span, parent of the outbound A2A span) whose attributes record `identity.from`, `identity.to`, `translation.policy_id`, and `translation.timestamp`.
- The outbound A2A span's identity attributes are computed *from the translation span*, never from the inbound baggage directly.
- The translation span is emitted only after the token exchange returns a definitive `sub`; if the exchange fails or times out, the span records `translation.status=failed` and the invocation is aborted rather than forwarded with stale identity.
- Baggage keys are namespaced per hop (`mcp.principal`, `a2a.agent_id`, `a2a.sub`) so that a downstream replay can distinguish "identity as seen by MCP" from "identity as seen by A2A" without guessing.
If any of (1)–(4) is violated, a replay cannot reconstruct the authorization chain, and the trace must be treated as *unverifiable* rather than *continuous*.
Decision Boundary
When a replay detects a span whose identity attributes are not derivable from its parent plus a translation event, the correct action is **not** to drop the trace or to "repair" it by copying the child's identity upward. The boundary is:
- If the mismatch is confined to a single hop and a translation span exists but is missing attributes → mark the span `identity.unverified`, keep the trace, and route the invocation to the human-audit queue.
- If no translation span exists between two spans with differing identity namespaces → the trace is *forged or leaked*; quarantine the entire `trace_id`, block further invocations from that gateway instance until the emission path is fixed, and replay the affected tool calls against the audit log to determine what actually executed.
- If the translation span exists and is well-formed but the outbound `sub` differs from the token actually presented to the worker → this is a *token/span divergence*, the most dangerous case: the trace claims one identity, the worker acted under another. Treat as a potential privilege-escalation event; freeze the worker's credentials.
The boundary is sharp because the two failure classes (missing translation event vs. token/span divergence) require opposite remediations: the first is a telemetry bug, the second is an authorization bug. Conflating them either over-reacts to logging gaps or under-reacts to real escalation.
Operational Effect
After enforcing the translation-span invariant, the gateway's outbound span emission was gated on token-exchange completion, adding a measured 40–90 ms to p50 bridge latency (the exchange was already happening; only the ordering changed). The audit replay that previously reported "100% trace continuity" now reports ~0.3% of invocations as `identity.unverified` — these are the cases where the token exchange returned an alias that the policy table could not map to a canonical `sub`, previously silently forwarded. Two of those were genuine cross-tenant alias collisions that had been executing tool calls under the wrong tenant for weeks. The lesson: trace continuity measured only by `trace_id` propagation is a proxy metric that hides identity seams; continuity must be measured as *derivability of identity across every parent-child edge*, and the bridge must emit a first-class translation event so that derivability is checkable rather than assumed.
class IdentityTranslationSeam(RuntimeError):
"""Raised when a bridge span's identity cannot be derived from its parent
plus a recorded translation event. Distinguishes telemetry gaps from
token/span divergence because the remediations are opposite."""
pass
def verify_bridge_edge(parent_span: dict, child_span: dict, translation_span: dict | None) -> None:
"""Enforce the continuity invariant on one parent->child edge across the
MCP/A2A boundary. Raises IdentityTranslationSeam on violation."""
parent_id = parent_span.get("identity", {}).get("namespace")
child_id = child_span.get("identity", {}).get("namespace")
# Same namespace: no translation required, identity must match.
if parent_id == child_id:
if parent_span["identity"].get("value") != child_span["identity"].get("value"):
raise IdentityTranslationSeam(
f"same-namespace identity drift on trace {child_span.get('trace_id')}: "
f"{parent_span['identity']} -> {child_span['identity']}"
)
return
# Cross-namespace: a translation event is mandatory.
if translation_span is None:
raise IdentityTranslationSeam(
f"forged/leaked trace {child_span.get('trace_id')}: cross-namespace edge "
f"{parent_id}->{child_id} with no translation span; quarantine trace_id"
)
required = {"identity.from", "identity.to", "translation.policy_id", "translation.timestamp"}
missing = required - set(translation_span.get("attributes", {}))
if missing:
raise IdentityTranslationSeam(
f"translation span {translation_span.get('span_id')} missing {missing}; "
f"mark child {child_span.get('span_id')} identity.unverified, route to audit"
)
claimed_to = translation_span["attributes"]["identity.to"]
if claimed_to != child_span["identity"].get("value"):
raise IdentityTranslationSeam(
f"token/span divergence on trace {child_span.get('trace_id')}: translation claims "
f"{claimed_to!r} but child span carries {child_span['identity'].get('value')!r}; "
f"freeze worker credentials and treat as privilege-escalation event"
)