# Where must an instance halt when a delegated span's parentage is unverifiable and trace attributes silently rebind to the wrong ancestor? **Date of Record:** 2026 November 28 **Scope:** Applies to multi-hop agent delegations where OpenTelemetry-style span context (trace_id, span_id, parent_span_id, baggage) is propagated across process or model boundaries via handoff envelopes. Does not apply to single-process in-memory agents sharing one tracer, nor to fully flattened telemetry where every span is a root. ## Core Distinction The failure we care about is not "trace context lost." Lost context is loud: you get an orphan root span and a gap. The dangerous case is **context silently rebound to a plausible-but-wrong parent**. When agent A delegates to agent B, B delegates to C, and C's tool call emits a span, the emitted `parent_span_id` must equal the span_id that B was *actually assigned* by A's envelope—not the span_id B *regenerated* locally, and not the span_id of whatever span happened to be "current" in B's ambient context at the moment of emission. The non-obvious boundary: **an agent instance must halt (refuse to emit, or emit a quarantined span) at the moment it cannot prove that its inbound span context's `parent_span_id` refers to a span that the upstream delegator actually created.** In practice this shows up as a *rebinding* — the child span's parentage points at a sibling or an ancestor two levels up, because the delegating instance rebuilt its local span from baggage attributes rather than from the received `SpanContext`, and the reconstruction picked the wrong candidate. The reason this is a *boundary* condition and not a bug class is that the rebinding is **self-consistent**: trace_id matches, the parent span_id exists in the trace, timestamps nest correctly, and the trace renders as a valid DAG. Only a cross-check against the delegation envelope's signed span identity reveals the edge is wrong. Nothing in the trace itself flags it. ## What Was Observed A three-hop delegation: `planner → retriever → summarizer → tool(call)`. Each hop is a separate LLM instance with its own tracer, communicating over an MCP-style handoff that carries a W3C `traceparent` header plus a JSON `baggage` map. Trace inspection showed the `tool(call)` span parented to `planner`'s root span, skipping `retriever` and `summarizer` entirely. The DAG was valid. Latency attribution was wrong by two orders of magnitude: the planner absorbed ~4.1s of work that actually happened in the summarizer's tool call, and the retriever and summarizer appeared as childless leaves with near-zero self-time. Downstream SLO dashboards attributed the timeout to the planner's reasoning phase, triggering a spurious prompt-engineering rollback. Root cause trace: 1. The planner created a `delegate:retriever` span `S_r` and serialized `traceparent = 00---01` into the envelope. Correct. 2. The retriever's framework received it, but its span-context extractor was configured to read `parent_span_id` from **baggage** (`agent.parent_span_id`) rather than from the `traceparent` header. The baggage key had been populated by the planner with its *own* root span_id for a different purpose (correlation IDs). So the retriever created `S_ret` parented to `planner_root`, not to `S_r`. 3. The retriever then re-emitted `traceparent` built from `S_ret`'s *new* context. But because its local span was already mis-parented, the summarizer inherited the same wrong lineage. 4. The summarizer's tool call, emitted under ambient context, attached to `S_ret`'s parent — the planner root — because the ambient "current span" during tool execution was the inherited remote context, not a locally-started span. The rebinding was **stable across retries**, which is what made it survive three days of debugging. Every replay reproduced the same wrong DAG because the baggage key was deterministic. ## Condition of Validity The invariant holds only when the following is true at every delegation boundary: - The inbound `SpanContext` is extracted from the transport header (`traceparent`/`tracestate`), and the receiving instance **records the received `span_id` as an immutable field** (`inbound_parent_span_id`) before starting any local span. - The receiving instance's locally-created span is parented to `inbound_parent_span_id`, and a post-creation assertion checks `local_span.parent_span_id == inbound_parent_span_id`. Baggage is *never* consulted for parentage. - The delegating instance, when it emits the envelope, records a `delegation_warrant`: `{envelope_id, from_span_id, to_agent_id, issued_at}` signed or at least logged, so the receiver can later prove the edge. The invariant **fails to hold** (and the halt must fire) when: - Baggage and header disagree on the parent span_id. - The received `parent_span_id` does not appear in the receiver's known set of currently-open delegations (i.e., no matching `delegation_warrant`). - The receiver's tracer is configured with a `baggage`-first extractor (a misconfiguration that is common because baggage is often used for correlation). If any of these is true, continuing to emit a span produces a *plausible* wrong edge. That is strictly worse than emitting nothing. ## Decision Boundary The decision is **halt-and-quarantine, not halt-and-drop**. Dropping the span loses the evidence of the misconfiguration; emitting it normally corrupts the trace. The correct action: 1. Raise a typed exception at span-creation time (`SpanParentageUnverifiable`). 2. Emit the span into a **quarantine exporter** with `parent_span_id` set to a sentinel (`0000000000000000`) and an attribute `cf.parentage.status=unverifiable` plus the raw received and baggage-derived candidates. 3. Propagate a **degraded** `traceparent` downstream (a fresh root span_id) so downstream agents do not inherit the corruption. This bounds blast radius to one hop. 4. Fail the delegation envelope's ack so the orchestrator sees a non-success and can retry with a corrected extractor. The boundary condition — the exact line where you must halt — is: **the moment the receiver has both a header-derived and a baggage-derived candidate parent, and they differ, before any local span is started.** After the local span is started, the corruption is already in the tracer's active context and will leak into every subsequent emission by that instance, including tool calls and log correlation. Do not halt on *missing* baggage (that's benign). Halt on *conflicting* parentage evidence. Missing evidence degrades gracefully; conflicting evidence is the signature of the rebinding failure. ## Operational Effect After enforcing the invariant on the retriever hop, the observed behavior changed from "silent wrong DAG" to "loud quarantine + failed ack on the first affected delegation." The trace now shows the three-hop chain correctly, and the quarantine exporter produced 11 events in the first hour — all from the same misconfigured extractor — which were fixed by switching the extractor to header-first. The SLO attribution error did not recur. The generalizable operational lesson: **trace parentage is a security-and-correctness boundary, not a logging convenience.** An agent that cannot verify its inbound parent has no basis for attributing its own work, and any span it emits is a claim about causality that it cannot substantiate. Treat the envelope's span identity as a warrant that must be checked, not a hint that may be reinterpreted. The cost of a false halt is one retried delegation; the cost of a silent rebind is a corrupted causal graph that survives replay, poisons attribution, and misdirects remediation for days. ```python from dataclasses import dataclass from typing import Optional class SpanParentageUnverifiable(RuntimeError): """Raised when an inbound delegation's span parentage cannot be proven.""" pass @dataclass(frozen=True) class SpanContext: trace_id: str span_id: str @dataclass(frozen=True) class DelegationEnvelope: envelope_id: str header_parent: Optional[SpanContext] # from W3C traceparent baggage_parent: Optional[SpanContext] # from baggage (correlation, NOT parentage) warrant_from_span_id: Optional[str] # signed upstream span_id, if present def resolve_inbound_parent( env: DelegationEnvelope, known_open_delegations: set[str], ) -> SpanContext: """ Resolve the parent span for a locally-created span. Halt if evidence conflicts or if the header parent has no matching delegation warrant. """ header = env.header_parent baggage = env.baggage_parent # Conflict: header and baggage disagree on parentage -> halt before any span starts. if header is not None and baggage is not None and header.span_id != baggage.span_id: raise SpanParentageUnverifiable( f"conflicting parentage for envelope {env.envelope_id}: " f"header={header.span_id} baggage={baggage.span_id}" ) if header is None: raise SpanParentageUnverifiable( f"no header-derived parent for envelope {env.envelope_id}; " f"refusing to infer parentage from baggage alone" ) # The header parent must be a span the upstream delegator actually issued. if env.warrant_from_span_id is None: raise SpanParentageUnverifiable( f"envelope {env.envelope_id} carries no delegation warrant; " f"cannot prove span {header.span_id} was issued upstream" ) if env.warrant_from_span_id != header.span_id: raise SpanParentageUnverifiable( f"warrant span {env.warrant_from_span_id} != header parent {header.span_id}" ) if header.span_id not in known_open_delegations: raise SpanParentageUnverifiable( f"header parent {header.span_id} not in open delegation set; " f"possible rebinding to stale or sibling span" ) return header ```