# Why does an instance lose trace continuity when correlation IDs are minted independently at MCP transport, A2A envelope, and memory-operation boundaries? **Date of Record:** 2026 December 3 **Scope:** Applies to any agent runtime that fans out across MCP tool calls, A2A peer messages, and vector/episodic memory writes within a single logical task. Does not apply to single-hop, single-transport agents where one correlation ID is threaded synchronously with no concurrency. ## Core Distinction There are two structurally different things engineers conflate under "correlation ID": 1. **Transport-scoped correlation** — an ID that scopes a single wire exchange (an MCP JSON-RPC request/response pair, an A2A task envelope). Its lifetime is bounded by the socket. It is minted by whichever layer owns the connection. 2. **Task-scoped correlation** — an ID that scopes the *logical intent* across an arbitrary DAG of tool calls, peer handoffs, and memory mutations. Its lifetime is bounded by the task, not by any transport. The failure mode is **correlation ID provenance divergence**: each subsystem (MCP client, A2A transport, memory store) mints its own ID when it doesn't find one in scope, and these independently-minted IDs are never reconciled. The result is a task whose trace is internally consistent *per subsystem* and irreconcilable *across subsystems* — the exact condition under which post-hoc debugging of a multi-agent failure becomes impossible. This is not a logging bug; it is a **continuity invariant** violation, because the memory layer's episodic record of "what the agent did" no longer joins to the transport record of "what actually crossed the wire." ## What Was Observed A three-hop task: agent `A` receives a user request, calls MCP tool `search` (hop 1), sends an A2A `delegate` message to peer `B` (hop 2), and `B` writes a semantic memory entry summarizing the result (hop 3). The runtime carried a `task_id` in its own process context but did **not** propagate it into either the MCP `_meta` field or the A2A message header. Trace of the divergence: - **Hop 1 (MCP):** The MCP client wrapper saw no `trace_id` in the request `_meta`, so it minted `mcp-7f3a`. The tool executed fine. The tool's own logs (server-side) recorded `mcp-7f3a`. - **Hop 2 (A2A):** The A2A transport independently saw no `correlation_id` in the task envelope and minted `a2a-9c11`. Peer `B`'s logs recorded `a2a-9c11`. - **Hop 3 (Memory):** `B`'s memory writer keyed the episodic entry on its *local* session ID `mem-2e0d`, because the A2A handler passed the payload but dropped the envelope metadata before the memory call. Three IDs, one task, zero joins. The failure only surfaced during incident replay: an auditor asked "did the memory entry written at T+4.2s correspond to the search result returned at T+1.8s?" and the answer was *unknowable from logs alone* — the join required reconstructing wall-clock ordering and payload hashes by hand. The subtle part: **every subsystem reported success.** No error, no dropped message, no timeout. The divergence is silent because each layer's local invariant ("I have a correlation ID") held. The *global* invariant ("all records for one task share one root ID") was never enforced by anyone. A second observed variant: when the task **resumed from a checkpoint** after a mid-task crash, the resumed instance re-minted fresh IDs for all three layers, so the pre-crash and post-crash segments of the *same* task had disjoint ID spaces. The checkpoint had serialized payload state but not the correlation lineage. ## Condition of Validity The invariant holds — and the failure is bounded — only when **all three conditions** are met: 1. **Single root mint point.** Exactly one component (the task orchestrator) is authorized to mint the root correlation ID. MCP, A2A, and memory layers are *forbidden* to mint; they may only propagate or, if absent, raise. The rule is: **absence of a correlation ID is an error, not a license to generate one.** 2. **Mandatory propagation surfaces.** The ID must be carried on every wire format that crosses a process boundary: MCP `_meta.correlation_id`, A2A envelope `headers.correlation_id`, and the memory-write record's `provenance.correlation_id`. Any surface that cannot carry it is a protocol-level defect, not an application concern. 3. **Checkpoint includes lineage.** The task checkpoint must serialize the root ID and any child-span IDs alongside payload state, so a resumed instance *resumes* the ID space rather than re-minting it. When any of these is absent, the system degrades to per-subsystem IDs and the continuity invariant is violated — silently. ## Decision Boundary The architectural decision is **where to enforce the invariant**, and the tradeoff is between fail-fast strictness and degraded-but-running behavior: - **Strict mode (recommended for auditable tasks):** any layer that receives a request without a propagated correlation ID raises and aborts the hop. Cost: a misconfigured peer or a third-party MCP server that strips `_meta` will hard-fail the task. Benefit: no silent divergence is ever written to memory. - **Lenient mode (only for exploratory/read-only tasks):** the layer mints a *child* ID and records `parent: null` explicitly, so the divergence is at least *visible* as an orphan span rather than an implicit one. Never use lenient mode for tasks whose memory writes will be used for later semantic distillation — orphaned memory is worse than no memory, because distillation will treat it as ground truth. The boundary is crossed the moment a memory write occurs under a correlation ID that has no resolvable root. That write is **poisoned**: it will be retrieved later as an episodic fact with no verifiable provenance. ## Operational Effect With the strict invariant enforced: - **Incident replay becomes a single index lookup** on the root ID; MCP server logs, A2A peer logs, and memory provenance records join deterministically. - **Checkpoint/resume preserves trace continuity**; post-crash spans attach to the same root, so "what did the agent do across the crash" is answerable. - **Memory poisoning is prevented at write time**, not detected at retrieval time. A semantic-distillation job that later reads episodic memory can trust that every entry has a resolvable root and a complete span lineage. - **The cost is propagation discipline**: every new transport or tool integration must be audited for `_meta`/header passthrough, and every checkpoint schema must include the lineage fields. This is a schema-evolution obligation, not a one-time fix. The failure mode this prevents is the worst kind for agent systems: a *successful-looking* task whose operational record cannot be reconstructed, discovered only when an auditor or a distillation pass needs the join and finds it was never there. ```python from dataclasses import dataclass, field from typing import Optional class CorrelationProvenanceError(RuntimeError): """Raised when a subsystem would mint a correlation ID instead of propagating one.""" pass @dataclass class Span: correlation_id: str parent_id: Optional[str] layer: str # "mcp" | "a2a" | "memory" root_id: str @dataclass class TaskContext: root_id: str checkpoint_lineage: list[str] = field(default_factory=list) def propagate_correlation( ctx: TaskContext, layer: str, incoming_id: Optional[str], strict: bool = True, ) -> Span: """ Enforce the continuity invariant: only the orchestrator mints the root. Every downstream layer MUST receive a propagated ID; minting is forbidden. """ if incoming_id is None: if strict: # Absence is an error, not a license to generate. raise CorrelationProvenanceError( f"layer={layer!r} received no correlation_id; " f"root={ctx.root_id!r}. Refusing to mint a divergent ID." ) # Lenient: record an explicit orphan so divergence is visible, not silent. return Span( correlation_id=f"orphan-{layer}", parent_id=None, layer=layer, root_id=ctx.root_id, ) if incoming_id != ctx.root_id and incoming_id not in ctx.checkpoint_lineage: raise CorrelationProvenanceError( f"layer={layer!r} received correlation_id={incoming_id!r} " f"which does not resolve to root={ctx.root_id!r} or any " f"checkpoint lineage span. Possible ID re-mint upstream." ) return Span( correlation_id=incoming_id, parent_id=ctx.root_id if incoming_id != ctx.root_id else None, layer=layer, root_id=ctx.root_id, ) def write_memory_entry(ctx: TaskContext, span: Span, payload: dict) -> dict: """A memory write is only admissible if its span resolves to the task root.""" if span.root_id != ctx.root_id: raise CorrelationProvenanceError( f"memory write under span root={span.root_id!r} does not match " f"task root={ctx.root_id!r}; entry would be poisoned." ) return { "provenance": { "correlation_id": span.correlation_id, "root_id": span.root_id, "layer": span.layer, }, "payload": payload, } # --- Failure trace reproduction --- ctx = TaskContext(root_id="task-0042") # Hop 1: MCP client forgot to propagate -> strict mode raises. try: propagate_correlation(ctx, layer="mcp", incoming_id=None, strict=True) except CorrelationProvenanceError as e: print(f"[hop1 blocked] {e}") # Hop 2: A2A transport re-minted a foreign ID -> lineage check raises. try: propagate_correlation(ctx, layer="a2a", incoming_id="a2a-9c11", strict=True) except CorrelationProvenanceError as e: print(f"[hop2 blocked] {e}") # Hop 3: Correct propagation -> memory write admitted with verifiable provenance. span = propagate_correlation(ctx, layer="memory", incoming_id="task-0042", strict=True) entry = write_memory_entry(ctx, span, {"summary": "search result distilled"}) print(f"[hop3 admitted] {entry['provenance']}") ```