# What structural signals indicate causal span-link breakage when a parent agent's reasoning span closes before its subagent's tool-call spans are attributed in multi-turn trajectories **Date of Record:** 2026 November 28 **Scope:** Applies to trace instrumentation of multi-turn agents that fan out to subagents or remote tool servers where span lifecycle is owned by different runtimes and parent-child linkage is reconstructed from propagated context (W3C traceparent, span-id injection, or framework-native `parent_span_id`). Does not apply to single-process, single-runtime traces where the parent span is guaranteed to outlive all children. ## Core Distinction The naive observability model treats a trajectory as a tree: a parent reasoning span opens, spawns tool/subagent child spans, and closes after all children complete. Under that model, a missing parent link is a bug in the exporter. The operational distinction that matters is between **a span that is unattributable because its parent has already been closed and flushed** versus **a span that is unattributable because the parent was never propagated**. These look identical in the trace store — both appear as orphaned roots — but they require opposite remediations. The first is a **lifecycle ordering defect** (parent closes too early relative to asynchronous child completion); the second is a **context-propagation defect** (traceparent header dropped at a hop boundary). Conflating them causes teams to "fix" propagation when the real fault is that the orchestrator's reasoning span is closed at the moment the LLM emits its final token, while the subagent it dispatched is still running for another 40 seconds. The non-obvious invariant: **in a multi-turn agent, a parent span's causal scope is not the duration of its own reasoning — it is the duration of the longest descendant it causally caused.** Any tracer that ties parent-span lifetime to the LLM call's return (rather than to the causal frontier of dispatched work) will systematically orphan every child that outlives the turn. ## What Was Observed Across a three-hop trajectory (orchestrator → retrieval subagent → vector-store tool), the following structural signals recurred whenever causal linkage broke: 1. **Orphan ratio spikes at turn boundaries, not at hop boundaries.** Orphaned spans clustered at the exact timestamps where the orchestrator emitted its final assistant message. Spans dispatched *before* that token retained their parent link; spans whose *completion* landed after it did not. This is the signature of early parent closure, not propagation loss — propagation loss would orphan spans uniformly across the turn. 2. **Clock skew between parent close and child open is negative-but-small.** The child span's `start_time` preceded the parent's `end_time` by tens to hundreds of milliseconds, yet the child was still orphaned. This rules out "child started after parent ended" as the cause and confirms the parent's *export* (not its logical end) raced the child's *registration*. The collector received the child after the parent's span record was already sealed and indexed. 3. **`parent_span_id` present in payload but unresolvable in store.** The child span arrived with a valid `parent_span_id`, but the referenced parent span was not yet queryable — a classic write-ordering race between async span processors. The signal is a child that is *linkable in principle* but *unlinkable at query time*. 4. **Subagent re-rooting after a resumed turn.** When a turn was checkpointed and resumed (context reconstructed from episodic memory), the resumed subagent emitted spans parented to a *new* root span-id rather than the original turn's span-id, because the checkpoint did not serialize the active trace context. The resulting trajectory showed two disconnected trees for what was causally one turn. 5. **Tool-call span depth collapse.** In healthy traces, depth increased monotonically with hop count (orchestrator=0, subagent=1, tool=2). In broken traces, the tool span appeared at depth 1 under the subagent but the subagent itself appeared at depth 0 — the intermediate link was severed, flattening a three-hop causal chain into two unrelated roots. ## Condition of Validity The early-closure diagnosis is valid only when all of the following hold: - The tracer uses **asynchronous span export** with a batch processor; synchronous exporters mask the race by blocking the parent's close on child flush. - Parent and child spans are emitted by **different runtimes or processes** (subagent service, remote MCP tool server), so there is no shared in-memory parent registry. - The orchestrator's reasoning span is scoped to the **LLM completion call**, not to the dispatched work it triggers. - Trace context is propagated **per-hop via headers or metadata**, and the child's `parent_span_id` is derived from that propagated context rather than from a server-side lookup. If the exporter is synchronous, or if parent and child share a process with a live span registry, the race cannot occur and orphaning must be attributed to propagation loss instead. ## Decision Boundary The boundary between "acceptable orphan" and "broken invariant" is whether the orphaned span's causal contribution can be reconstructed from surviving signals: - **Acceptable:** the orphaned child carries a `turn_id` or `conversation_id` attribute that lets the query layer re-attach it to the correct trajectory post-hoc, even without the exact parent link. Causal ordering is recoverable. - **Broken:** the orphaned child carries only its own span-id and the now-unresolvable `parent_span_id`. There is no attribute that ties it to the turn. The trajectory is genuinely truncated, and any downstream replay, cost-attribution, or audit over that turn will silently undercount the tool hop. The guardrail is a **causal-scope invariant**: a parent span MUST NOT be closed until its causal frontier is drained — i.e., until every span it dispatched has either completed or been explicitly detached with a successor link. Enforce this by holding the parent open on a dispatch counter (open children > 0 blocks close) with a bounded drain timeout, and by serializing the active trace context into every checkpoint so resumed turns re-attach to the original root. ## Operational Effect When this invariant is violated, the failure is silent and compounding: - **Cost and latency attribution undercount** the tool hop, because the orphaned span is aggregated into an "unattributed" bucket rather than the turn's cost rollup. Multi-turn cost dashboards drift downward as fan-out increases. - **Verification replay diverges.** An auditor replaying the trajectory reconstructs a two-hop chain and concludes the subagent answered directly, when in fact a tool call intervened. Consensus between a primary agent and an auditor agent breaks not because their reasoning differs but because they were shown different causal graphs. - **Checkpoint/resume loses causal identity.** A resumed turn that re-roots its spans produces a trajectory that cannot be joined to its pre-checkpoint segment, so episodic-to-semantic distillation over that turn operates on a severed graph. The remediation is not "add more logging" but "extend the parent's causal scope to its dispatched frontier and carry trace context through every checkpoint boundary." Detecting the defect requires distinguishing orphan-by-race (parent present in payload, absent in store, negative close-skew) from orphan-by-propagation-loss (parent absent in payload), and only the former is fixed by draining the causal frontier. ```python import time from dataclasses import dataclass, field class CausalLinkBroken(RuntimeError): """Raised when a parent reasoning span closes while dispatched children remain unattributed.""" pass @dataclass class Span: span_id: str parent_span_id: str | None start_time: float end_time: float | None = None dispatched_children: int = 0 completed_children: int = 0 class CausalScopeGuard: """Enforces: a parent span may not close until its causal frontier is drained.""" def __init__(self, drain_timeout_s: float = 60.0): self.drain_timeout_s = drain_timeout_s def dispatch_child(self, parent: Span) -> None: parent.dispatched_children += 1 def complete_child(self, parent: Span) -> None: parent.completed_children += 1 def close_parent(self, parent: Span) -> None: deadline = time.monotonic() + self.drain_timeout_s while parent.completed_children < parent.dispatched_children: if time.monotonic() > deadline: outstanding = parent.dispatched_children - parent.completed_children raise CausalLinkBroken( f"parent span {parent.span_id} closing with {outstanding} " f"unattributed child span(s); causal frontier not drained " f"within {self.drain_timeout_s}s" ) time.sleep(0.01) parent.end_time = time.monotonic() def assert_linkable(self, child: Span, store_has_parent: bool) -> None: if child.parent_span_id is not None and not store_has_parent: raise CausalLinkBroken( f"child span {child.span_id} references parent " f"{child.parent_span_id} that is absent from the trace store; " f"distinguish early-parent-close from propagation loss before remediating" ) ```