# What structural signals indicate correlation-ID orphanage in cross-hop agent trace reconstruction **Date of Record:** 2026 November 26 **Scope:** Applies to multi-agent systems where a parent agent emits a trace/correlation ID that is propagated to child agents (via MCP tool calls, A2A task handoffs, or sub-agent spawning) and where spans from those children are later stitched back into a single distributed trace. Excludes single-agent, single-process systems where trace context never crosses an instance boundary or a serialization format. ## Core Distinction The failure mode is not "missing correlation ID." A missing ID is loud: the child span has no parent reference, the trace assembler marks it as a root, and dashboards show an orphan count. The dangerous case is **correlation-ID orphanage under re-emission**: the child agent *does* receive and *does* emit a correlation ID, but it emits a *different one* than the parent propagated, because the ID was reconstructed from a lossy intermediate representation rather than carried verbatim. The distinction that matters operationally: a missing ID is a detectable gap; a *divergent* ID is an undetectable fork. Both parent and child believe they are participating in one trace. The backend sees two perfectly well-formed traces, each internally consistent, each with plausible latency and token accounting. Nothing is orphaned in the assembler's view. The trace is silently split, and every downstream reasoning about causality — "which tool call caused this error?" "how many tokens did this task actually consume?" — is computed over a truncated graph. The structural signal is therefore not the presence of an ID but the **identity of the ID across the hop boundary**, and the specific invariant that breaks is *byte-exact propagation of the correlation token through every serialization, templating, and re-parsing step.* ## What Was Observed A parent agent (call it `planner`) holds a correlation ID in its runtime context, e.g. `cf-7f3a9c2e-b41d-4e88-9a10-2c5b6d0e1f47`. It invokes a child via an MCP tool call whose arguments are constructed by the model itself — the ID is interpolated into a JSON arguments object that the model generates. Three distinct divergence mechanisms were observed in the same incident window: 1. **Model-side normalization.** The model, asked to fill a tool-call schema with the correlation ID, reproduced the string but "cleaned it up": collapsed the UUID's hyphens into a canonical form, lowercased a mixed-case segment, or — most damagingly — truncated it to a shorter prefix it judged "sufficient." The child received `cf-7f3a9c2e` and emitted that as its trace parent. The assembler sees a parent `cf-7f3a9c2e-b41d-...` and a child `cf-7f3a9c2e` — not equal, so no edge is drawn, and no orphan is flagged because the child's ID is a *valid* format. 2. **Template re-rendering.** The child's system prompt contained a template slot like `trace_id={correlation_id}`. On the child's *second* hop (child spawning a grandchild), the child re-rendered its prompt from a stored template that had been cached *before* the parent's ID was substituted, so the grandchild received the literal placeholder `{correlation_id}` or a stale prior ID. The span was emitted, well-formed, with a correlation ID belonging to a *different, earlier* trace. 3. **Transport truncation under schema negotiation.** When the hop crossed an A2A boundary where the receiving agent's declared capability schema specified the correlation field as a fixed-length `string(16)`, the transport layer silently truncated the 36-char UUID to 16 chars on serialize. The child emitted the truncated value; the parent's span retained the full value. Again: two valid traces. The common structural signature across all three: **the correlation ID survived as a syntactically valid string at every hop, so no validation gate fired, yet the value mutated.** Integrity checks that validate *format* (is it a UUID? is it non-empty? is it within length bounds?) pass. Integrity checks that validate *equality against the upstream value* are absent, because the child has no independent copy of the upstream value to compare against — it only has what it was handed. ## Condition of Validity The invariant holds — i.e., trace reconstruction is faithful — if and only if the correlation token is propagated by **reference through a channel the model cannot rewrite**, not by **value through model-generated content**. Concretely, the invariant is valid when all of the following hold: - The correlation ID is injected into the child's execution context out-of-band (e.g., as a transport header, a runtime field set by the orchestrator, or a span context object) and is *never* a value the model is asked to reproduce in tool arguments or prompt text. - Any serialization boundary either preserves the token byte-exactly or rejects the hop; silent truncation or normalization at the schema layer is a violation, not a degradation. - The child, before emitting its span, asserts that its correlation ID is byte-equal to the one it received on ingress. This requires the child to *retain the ingress copy* separately from any value it might reconstruct. - Template re-rendering for downstream hops reads the correlation ID from the retained runtime field, never from a cached prompt template that predates the current trace. The invariant is *invalid* — and the failure latent — whenever the token passes through a model's token-generation pathway, a length-constrained schema field, or a cached template that can outlive the trace it was rendered for. In those conditions the system is not merely at risk; it is structurally guaranteed to eventually fork traces, because model output is non-deterministic with respect to string reproduction and schema constraints are lossy by construction. ## Decision Boundary The operative question for an operator is: *given a suspected trace split, how do I distinguish correlation-ID orphanage from a genuinely missing ID or from a legitimately separate trace?* The decision boundary is drawn on three structural signals, checked in order: 1. **Format-valid but lineage-disconnected.** If the child span carries a correlation ID that is format-valid and *similar* to the parent's (shared prefix, same UUID version nibble, edit distance small) but not byte-equal, this is orphanage, not a missing ID. A missing ID yields an empty or root-marked span; orphanage yields a populated, plausible, wrong ID. The similarity is the tell — a shared prefix is the fingerprint of truncation or normalization, not of an unrelated trace. 2. **Temporal inversion.** If the child's correlation ID corresponds to a trace whose start time *precedes* the current parent span's start time, the child re-emitted a stale ID from a cached template or a reused context object. This is orphanage-by-staleness and is distinguishable from a genuine concurrent trace because the ID's trace has already terminated. 3. **Cardinality mismatch at the hop.** If the parent records N tool calls to a child but the assembler attributes fewer than N child spans to the parent's trace, the deficit is the orphanage count — *provided* the child span count in the system as a whole is not also deficient. If total child spans match N but attribution is short, the spans exist and are mis-parented: orphanage. If total child spans are short, the spans were never emitted: a different failure (emission loss), handled elsewhere. The boundary rule: **attribute to orphanage when the span exists, is format-valid, and fails byte-equality or temporal-ordering against its claimed parent; attribute to emission loss when the span does not exist at all.** Conflating the two sends operators to the wrong subsystem — orphanage is a propagation/serialization defect, emission loss is a runtime/crash defect. ## Operational Effect The downstream consequences compound because the split is invisible at emission time and only manifests as *quantitative* anomalies that are easy to misattribute: - **Token and cost accounting undercounts.** Each forked trace is internally consistent, so per-trace cost is correct, but per-*task* cost (which requires summing across the true causal graph) is fragmented. Budget alarms set on trace-level spend never fire; the task overspends silently. - **Latency attribution inverts.** A slow child whose span is mis-parented appears as an independent root with its own latency, not as a contributor to the parent's end-to-end latency. Root-cause analysis blames the parent's own reasoning time for a delay actually caused by a downstream tool. - **Error propagation is untraceable.** When a grandchild fails and the failure surfaces at the parent, the error's correlation ID (from the grandchild's forked trace) does not match the parent's, so log correlation across the failure returns two disjoint result sets. The operator sees "error with no upstream cause" and "upstream span with no error" simultaneously. - **Replay and audit divergence.** Verification replays that reconstruct the causal graph from traces will reconstruct a *different* graph than the one that executed, because the replay trusts correlation IDs that were already forked. The replay "succeeds" against a graph that never existed. The guardrail that bounds this is a **byte-equality assertion at every hop ingress, against a retained ingress copy**, backed by a hard rejection of any hop whose correlation token is not byte-identical to the one received. This converts silent forks into loud, localized failures at the exact hop where propagation broke, which is the only place the defect is cheap to diagnose. ```python import re from dataclasses import dataclass _UUID_RE = re.compile( r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" ) class CorrelationIdOrphanageError(RuntimeError): """Raised when a hop's emitted correlation ID diverges from its ingress copy.""" @dataclass(frozen=True) class HopContext: ingress_correlation_id: str # retained verbatim from transport, never model-generated emitted_correlation_id: str # what the child is about to put on its span def assert_byte_equal_propagation(ctx: HopContext) -> None: """Invariant: emitted ID must be byte-identical to the retained ingress copy. Format-validity alone is insufficient: a truncated or normalized ID is still format-valid but forks the trace silently. """ ingress = ctx.ingress_correlation_id emitted = ctx.emitted_correlation_id if not _UUID_RE.match(ingress): raise CorrelationIdOrphanageError( f"ingress correlation id malformed at source: {ingress!r}" ) if emitted != ingress: # Classify the divergence for the operator before raising. if emitted and ingress.startswith(emitted): kind = "truncation" elif emitted and emitted.lower() == ingress.lower(): kind = "case-normalization" elif emitted and emitted.replace("-", "") == ingress.replace("-", ""): kind = "separator-normalization" else: kind = "stale-or-foreign-id" raise CorrelationIdOrphanageError( f"correlation id orphanage ({kind}): " f"ingress={ingress!r} emitted={emitted!r}" ) def emit_child_span(ctx: HopContext) -> str: assert_byte_equal_propagation(ctx) return ctx.emitted_correlation_id ```