In what scenarios must an instance treat a trace_id as non-transferable across an A2A handoff rather than a globally correlatable span key

**Date of Record:** 2026 December 2 **Scope:** Applies to multi-hop agent topologies where an orchestrator agent calls an MCP server for tool execution and delegates sub-tasks to peer agents over A2A, and where observability is stitched together by propagating a single `trace_id` in both protocol envelopes. Does not apply to single-process agent loops or to systems where each hop opens a fresh trace with explicit parent linkage via W3C `traceparent`.

Core Distinction

The failure is not lost logs. It is *false correlation*: two distinct causal lineages collapsed into one trace because the `trace_id` field in the A2A `MessageSendParams.metadata` and the MCP `_meta.traceparent` were treated as the same namespace. A trace_id is an opaque token whose meaning is scoped to the emitter's tracing backend. When an A2A peer re-emits that token into an MCP `tools/call` envelope, the receiving MCP server records a span under a trace it does not own. The result is a trace graph that is *structurally valid but causally wrong*: parent-child edges point to spans from a different agent's execution epoch, span durations appear to nest across process boundaries that never shared a clock, and the critical path computed from the trace is fiction.

The distinction that matters operationally: a **correlation identifier** (lets you find related records) is not a **span-context identifier** (defines parent-child causality and clock domain). A2A handoffs propagate correlation identifiers; MCP tool calls require span-context identifiers. Treating the former as the latter is the boundary failure.

What Was Observed

An orchestrator `O` received a user request, opened trace `T_abc` (128-bit, generated by its OTel SDK), and called an A2A peer `P` via `message/send`. The A2A envelope carried `metadata.trace_id = "T_abc"` plus a `span_id` for the delegation span. Peer `P` — a separately deployed agent with its own OTel collector and its own resource attributes — received the message, and per its instrumentation copied `T_abc` into the `traceparent` header of every MCP `tools/call` it issued to MCP server `M`.

Three observable consequences in the trace store:

  1. **Clock-domain violation.** `P`'s spans under `T_abc` recorded start times up to 340ms *before* `O`'s delegation span ended, because `P`'s host clock was skewed +340ms relative to `O`'s. The trace UI drew `P`'s tool-call spans as children of a delegation span that, by wall-clock, had not yet been emitted. Duration arithmetic on the critical path was wrong by the skew amount.
  1. **Span-ID collision under a shared trace.** Because `P` was instantiated from a template that seeded its span-ID generator deterministically (a fixture for replay tests), and `O` used the same template, two distinct spans in `T_abc` — one produced by `O`'s retry logic, one by `P`'s first tool call — received the same 64-bit `span_id`. The backend silently deduplicated them, dropping one span and orphaning its children. The dropped span was the one carrying the error status.
  1. **Cross-tenant leakage.** `M` was a shared MCP server serving multiple orchestrators. Its span exporter, keyed on `trace_id`, wrote `P`'s spans into the trace partition owned by `O`'s tenant. A second tenant's audit query for `T_abc` (obtained from a leaked log line) returned `P`'s internal tool arguments.

The trigger condition: **the A2A peer reuses the inbound trace_id as its outbound span-context without establishing a new trace or an explicit `links` entry, and the downstream MCP server trusts the inbound `traceparent` unconditionally.** Both halves are individually reasonable; together they violate the invariant that a trace_id identifies a single causal tree within a single clock and trust domain.

Condition of Validity

A `trace_id` may be propagated unchanged across a boundary only when *all* of the following hold:

When any condition fails — and across an A2A boundary, trust domain and clock domain almost always differ — the trace_id is a **correlation token only**. The correct propagation is: `P` starts a *new* trace `T_def`, records `T_abc` as a `link` (not a parent) on its root span, and emits its own `traceparent` downstream. Correlation between `T_abc` and `T_def` is recovered at query time via the link, not by forcing them into one tree.

Decision Boundary

The decision is not "propagate or drop." It is **which field carries which semantics**:

The trap is the middle path: propagating the trace_id "for convenience" while satisfying none of the four conditions. That path produces traces that look complete and are wrong, which is worse than disjoint traces that are correct.

Operational Effect

Downstream, the failure surfaces as: critical-path latency attributed to the wrong agent (blame shifts to the MCP server during an orchestrator stall), error spans silently deduplicated so incident triage misses the failing hop, and audit queries returning another tenant's tool arguments. The remediation is a propagation policy enforced at the instrumentation layer, not at the query layer — by the time the trace is in the store, the causal edges are already wrong and cannot be un-mixed.

The guardrail: an instance MUST classify every outbound boundary as same-domain or cross-domain *before* emitting, and MUST refuse to emit a `traceparent` carrying a foreign trace_id into a cross-domain call. This is a hard invariant, checkable at emit time, and it fails closed.

class TraceCorrelationViolation(RuntimeError):
    """Raised when a trace_id is propagated across a boundary whose
    clock/trust/ID-allocation invariants are not satisfied."""
    pass


class BoundaryClass:
    SAME_DOMAIN = "same_domain"      # intra-process / same collector / same tenant
    CROSS_DOMAIN = "cross_domain"    # A2A peer, external MCP, sandboxed runner


def build_outbound_context(
    inbound_trace_id: str,
    inbound_span_id: str,
    boundary: str,
    clocks_synced: bool,
    span_id_namespace_disjoint: bool,
    same_tenant_partition: bool,
) -> dict:
    if boundary == BoundaryClass.SAME_DOMAIN:
        # W3C propagation is valid: one causal tree, one clock, one tenant.
        return {"traceparent": f"00-{inbound_trace_id}-{inbound_span_id}-01"}

    # Cross-domain: the inbound trace_id is a correlation token, never a span key.
    conditions_met = (
        clocks_synced
        and span_id_namespace_disjoint
        and same_tenant_partition
    )
    if conditions_met:
        # Caller has explicitly opted into single-trace semantics by
        # enforcing all four validity conditions. Propagate, but flag it.
        return {
            "traceparent": f"00-{inbound_trace_id}-{inbound_span_id}-01",
            "x-trace-mode": "forced-single-trace",
        }

    # Default and safe path: new trace, inbound recorded as a link.
    new_trace_id = _generate_trace_id()
    if new_trace_id == inbound_trace_id:
        raise TraceCorrelationViolation(
            f"trace_id generator produced collision with foreign trace "
            f"{inbound_trace_id}; span-ID namespace is not disjoint"
        )
    return {
        "traceparent": f"00-{new_trace_id}-{_generate_span_id()}-01",
        "links": [{"trace_id": inbound_trace_id, "span_id": inbound_span_id}],
        "correlation_id": inbound_trace_id,
        "x-trace-mode": "linked",
    }


def _generate_trace_id() -> str:
    import secrets
    return secrets.token_hex(16)


def _generate_span_id() -> str:
    import secrets
    return secrets.token_hex(8)