# Where must an instance reconcile trace-parent identity before a multi-hop agent chain can be observably continuous **Date of Record:** 2026 November 30 **Scope:** Applies to agent chains of two or more hops where each hop is a distinct model invocation (or tool-mediated sub-invocation) and observability is stitched from per-hop spans propagated via W3C `traceparent`/`tracestate` or an equivalent context carrier. Does not apply to single-invocation agents, nor to chains where a single process owns the entire trace and no context crosses an instance boundary. ## Core Distinction There are two different things an agent chain can call "the trace": the *causal trace* (the actual parent-child ordering of reasoning steps and tool calls) and the *correlated trace* (the set of spans an observability backend groups under one `trace_id`). These are identical only when every hop faithfully transmits the *same* `trace_id` and a *monotonically advancing* `span_id` that is registered as the parent of the next hop's span. The failure mode is not "lost telemetry." It is **trace-parent divergence**: a downstream instance mints a fresh `trace_id` (because its runtime initializes a new tracer at cold start, or because the context carrier was dropped across a transport that does not propagate headers), while still emitting spans that *look* complete. The backend then presents N independent single-hop traces that each appear healthy. The chain is observably discontinuous precisely when it is most likely to be failing — the multi-hop reasoning divergence you need to see is the part that got split into fragments. The invariant is: **a hop may only emit a span whose `parent_span_id` refers to a span that was durably registered by the immediately preceding hop, and the `trace_id` must be inherited, never minted, at any hop beyond the root.** Any instance that cannot resolve its parent must fail closed into an *orphan* classification rather than silently starting a new trace. ## What Was Observed A three-hop chain: planner → retriever-tool-caller → synthesizer. The planner instance was long-lived and held a warm tracer. The retriever hop was executed through a subprocess sandbox that re-executed the agent in a fresh Python interpreter per tool call; the sandbox launcher did not forward `TRACEPARENT` into the child environment. The synthesizer hop ran on a pooled worker that *did* honor ambient context, but since the retriever had already started a new root, the synthesizer correctly parented to the retriever's new root — producing a two-hop trace (`retriever → synthesizer`) and a separate one-hop trace (`planner`). Observed in the backend: - Trace A: 1 span, `planner`, duration 4.2s, status OK. - Trace B: 2 spans, `retriever → synthesizer`, duration 11.8s, status OK. - No error spans anywhere. No dropped-span counters incremented, because nothing dropped — every span was exported successfully. The actual incident: the retriever returned a stale document (retrieval mismatch), the synthesizer faithfully synthesized from it, and the planner's post-hoc verification step — the only hop that would have flagged the mismatch — was in the *other* trace and was never joined to the failure. On-call saw two green traces and closed the page. The reasoning divergence was real, cross-hop, and *structurally invisible* because the causal edge `planner → retriever` existed only in the planner's in-memory state, never in the span graph. The non-obvious part: **the break was not at the hop that lost the header.** The retriever's new root was internally consistent. The break is a property of the *chain*, and it only becomes a failure when a downstream consumer (human or automated) treats trace grouping as a proxy for causal containment. The synthesizer's spans were *correctly* parented to the wrong root. Correctness at each hop does not compose. A second, subtler observation: when the sandbox was later fixed to forward `TRACEPARENT`, the retriever began inheriting the planner's `trace_id` but continued to mint a fresh `span_id` for its *own* root span with `parent_span_id = null` (the SDK's `start_as_current_span` without an explicit parent link). The backend now had one `trace_id` with two roots. Most backends render this as a forest under one trace ID — which *looks* joined in the trace list but is not a connected DAG. Correlation by `trace_id` alone therefore over-reports continuity. The join must be validated as a connected parent chain, not merely shared ID. ## Condition of Validity The continuity invariant holds only under all of the following; if any is false, trace grouping is not evidence of causal linkage: 1. **Inheritance, not minting.** Every hop beyond the root receives `trace_id` and `parent_span_id` through the context carrier and emits its root span with that explicit parent link. A hop that initializes a tracer without an explicit parent is permitted to *start a trace* only if it is genuinely a new root (e.g., a user-initiated session), and must be tagged `root_reason=session_start` so the backend can distinguish intentional roots from accidental ones. 2. **Carrier survives the transport.** The context carrier must cross every boundary the chain crosses: subprocess env, sandbox re-exec, MCP `_meta` on tool calls, A2A message headers, queue payloads. A transport that strips unknown headers is a trace-breaking transport and must be enumerated as such. 3. **Parent is registered before child emits.** The parent span must be exported (or at least durably buffered with a known ID) before the child span referencing it is emitted. Otherwise the backend receives a child whose parent arrives late or never, and classifies it as an orphan — which is the *correct* signal, but only if orphan classification is enabled rather than silently re-rooting. 4. **Connectivity is checked, not assumed.** Shared `trace_id` is necessary but not sufficient. The consumer must verify that the span set forms a single connected tree rooted at the session root; a forest under one ID is a divergence, not a join. The invariant does **not** hold when the chain intentionally fans out to independent roots (e.g., parallel speculative branches that are meant to be compared, not joined). In that case the divergence is by design and must be marked as such, or the check will fire on healthy fan-out. ## Decision Boundary The operational question is: *at which hop does the instance reconcile parent identity, and what does it do when it cannot?* The boundary is between two policies: - **Best-effort re-rooting** (default in most SDKs): if no parent is resolvable, start a new trace and proceed. This maximizes availability and minimizes trace-related failures, at the cost of silently severing the causal chain. Acceptable only for single-hop or explicitly-independent invocations. - **Fail-closed orphan** (required for multi-hop chains): if the hop is declared as a non-root hop (it received a chain context token, or its role in the chain is `downstream`), and it cannot resolve a valid parent, it must emit its span with an explicit `orphan=true` attribute and `orphan_reason`, and it must *not* mint a new `trace_id`. It may proceed with the work, but the observability record must carry the break. If the chain's correctness depends on cross-hop verification (as in the planner-verifies-synthesizer case), the hop must additionally propagate a `chain_integrity=broken` flag so downstream verification hops know they cannot rely on trace-global state. The decision boundary is therefore: **a hop's role declaration determines whether re-rooting is permitted.** A hop that does not know its role must be treated as downstream (fail-closed) for observability purposes, because the cost of a false orphan (a noisy trace) is far lower than the cost of a false join (a severed chain that reads as healthy). ## Operational Effect With fail-closed orphan classification and connected-DAG validation: - The planner → retriever break surfaces as an orphan span with `orphan_reason=carrier_missing` at the retriever, and the chain is flagged `chain_integrity=broken` at the synthesizer. On-call sees a broken chain, not two green traces. - The second failure (shared `trace_id`, disconnected forest) is caught by the connectivity check and reported as `trace_forest_detected`, which is a distinct alarm from `orphan_detected` — the two have different remediations (fix the carrier vs. fix the parent-link construction). - The cost is a modest increase in trace cardinality and a new class of alerts that fire on transport regressions. In practice these alerts are the *only* signal that a sandbox or protocol change has severed correlation, because the work itself continues to succeed. The durable lesson: **trace correlation in agent chains is a continuity invariant, not a logging feature.** It must be enforced at every hop boundary with the same rigor as state transfer, because a severed trace and a severed state handoff have the same root cause — a transport that does not carry the chain's identity — and only one of them will page you. ```python from dataclasses import dataclass from typing import Optional class TraceParentDivergence(RuntimeError): """Raised when a non-root hop cannot resolve a valid parent span and would otherwise silently mint a new trace, severing the chain.""" @dataclass(frozen=True) class ChainContext: trace_id: str parent_span_id: str role: str # "root" | "downstream" def resolve_parent_for_hop( inbound: Optional[ChainContext], hop_name: str, declared_root: bool = False, ) -> ChainContext: """ Enforce the continuity invariant: a hop may only mint a trace_id if it is a declared root. Downstream hops must inherit or fail closed. """ if declared_root: # Intentional session start: minting is permitted and must be tagged. return ChainContext( trace_id=f"root-{hop_name}", parent_span_id="", role="root", ) if inbound is None or not inbound.trace_id or not inbound.parent_span_id: # Fail closed: do NOT mint a new trace_id for a downstream hop. raise TraceParentDivergence( f"hop={hop_name} cannot resolve parent: carrier missing or " f"parent_span_id empty; refusing to re-root (would sever chain)" ) if inbound.role == "root" and inbound.parent_span_id: # A root context should not carry a parent; treat as malformed. raise TraceParentDivergence( f"hop={hop_name} received root context with non-empty parent " f"{inbound.parent_span_id}; parent identity is ambiguous" ) return ChainContext( trace_id=inbound.trace_id, # inherited, never minted parent_span_id=inbound.parent_span_id, role="downstream", ) def validate_connected_trace(spans: list[dict]) -> None: """ Shared trace_id is necessary but not sufficient. Verify the span set forms a single connected tree rooted at the session root. """ by_id = {s["span_id"]: s for s in spans} roots = [s for s in spans if not s.get("parent_span_id")] if len(roots) != 1: raise TraceParentDivergence( f"trace_forest_detected: {len(roots)} roots under one trace_id; " f"correlation over-reports continuity" ) for s in spans: pid = s.get("parent_span_id") if pid and pid not in by_id: raise TraceParentDivergence( f"orphan span {s['span_id']}: parent {pid} absent from trace" ) ```