# Where must an instance bound causal span linkage when a tool-call graph re-enters a prior decision node **Date of Record:** 2026 December 1 **Scope:** Applies to agents whose decision traces are reconstructed by linking GenAI spans (model invocation, tool call, tool result) into a causal DAG for post-hoc audit or replay. Does not apply to flat per-turn logging without cross-span parentage, nor to single-shot inference with no tool re-entry. ## Core Distinction A causal tool-call graph is *acyclic by construction* only if every span has exactly one parent and tool results are terminal. Real agents violate this: a tool result re-enters the reasoning loop and produces a *new* model span that is causally downstream of an *earlier* decision node it also semantically depends on. The distinction that matters operationally is between **temporal parentage** (span B started after span A finished, so B.parent = A) and **causal parentage** (B's inputs were derived from A's output *and* from a prior decision D that B re-evaluates). Span linking schemes that collapse these two into a single `parent_span_id` field silently rewrite the graph into a tree, and the tree lies about re-entry. The failure is not "missing spans." Every span is present and correctly timestamped. The failure is that the *edge set* is wrong: a re-entrant model span that consults tool result R and re-reads decision D is recorded with parent R only, erasing the D→B edge. An auditor replaying the trace sees a linear chain and concludes the agent never revisited D, when in fact the second visit is where the divergence originated. ## What Was Observed A three-tool agent (search → fetch → summarize) was tasked with a retrieval-then-verify loop. Trace excerpt as reconstructed from `parent_span_id` alone: ``` span_1 genai.model parent=null decision: "search for X" span_2 genai.tool parent=span_1 tool: search("X") -> hits span_3 genai.model parent=span_2 decision: "fetch hit[0]" span_4 genai.tool parent=span_3 tool: fetch(url0) -> doc span_5 genai.model parent=span_4 decision: "summarize doc" span_6 genai.tool parent=span_5 tool: summarize(doc) -> summary span_7 genai.model parent=span_6 decision: "summary contradicts span_3 premise; re-fetch hit[1]" ``` The tree reports a clean linear pipeline. But span_7's prompt contained the *original* decision text from span_3 (the premise being contradicted) plus the summary from span_6. The D=span_3 → span_7 edge exists in the actual dataflow and is absent from the recorded graph. During incident review, an engineer asked "did the agent ever reconsider its fetch choice?" The trace said no. The agent's own prompt history said yes. The graph was the artifact of record and it was wrong. A second observation: when the same mechanism ran under a retry wrapper, span_7 was emitted twice (span_7a, span_7b) with identical `parent_span_id=span_6`, producing a *fork* that the tree renderer displayed as parallel branches. The two spans were not parallel — 7b was a retry of 7a with the same inputs, and the fork implied a nondeterministic branch point that did not exist. Causal ambiguity was manufactured by the retry, not by the model. ## Condition of Validity The single-parent span link is a valid causal record **iff** the agent's execution is a strict call tree: every model invocation consumes only its immediate predecessor's output, and no span re-reads state produced by a non-ancestor. This holds for stateless single-pass tool use. It fails the moment either of the following is true: 1. **Re-entry**: a span's input set intersects the output set of a non-parent ancestor (the verification loop above). 2. **Retry convergence**: two spans share a parent and identical input digests but differ only in attempt counter — a fork that is not a decision fork. The invariant required to keep the graph honest is: *every span must carry an explicit `causal_inputs` set of span IDs whose outputs were in its prompt or tool arguments, and this set must be a superset of `{parent_span_id}`.* Parentage is then the temporal spine; `causal_inputs` is the actual DAG. Audit tooling must traverse `causal_inputs`, not `parent_span_id`, and must reject any span where `parent_span_id ∉ causal_inputs`. ## Decision Boundary The boundary is between **recording what happened in time** and **recording what informed the decision**. Below the boundary (flat logging, no replay requirement) timestamps and parent IDs suffice. Above the boundary — any system that will be asked "why did the agent do this?" or replayed to reproduce a decision — the single-parent field is insufficient and must be augmented at emission time, because it cannot be reconstructed later. The reconstruction attempt fails specifically when the prompt that produced a span is no longer retained (context-window eviction, truncation) and the only surviving evidence of the D→B edge is the model's own output text, which is probabilistic and may not mention D at all. Once the prompt is gone, the causal edge is unrecoverable; the graph is permanently degraded to a tree. The decision: emit `causal_inputs` at span close, before prompt eviction, and treat any span with an empty `causal_inputs` (other than the root) as a trace-integrity violation that blocks replay. ## Operational Effect With `causal_inputs` enforced, the verification loop above reconstructs as span_7 with `causal_inputs={span_3, span_6}`, and the replay tool correctly identifies span_3 as the contradicted premise, enabling a diff of "what the agent believed at span_3 vs. what it re-derived at span_7." Without it, incident review systematically undercounts re-entry, attributes divergence to the last tool call, and misses the actual decision point. The retry fork is resolved by keying on input digest: identical-digest siblings collapse to one logical node with an attempt vector, so the renderer no longer fabricates a branch. The cost is one additional field per span and a validation gate at emission; the failure mode it prevents is a confidently wrong audit trail, which is worse than no trail because it is trusted. ```python class CausalLinkIntegrityError(RuntimeError): """Raised when a GenAI span's recorded causal inputs do not form a valid DAG edge set.""" pass def validate_span(span: dict, known_spans: dict[str, dict]) -> None: span_id = span["span_id"] parent = span.get("parent_span_id") causal = span.get("causal_inputs") if causal is None: raise CausalLinkIntegrityError( f"span {span_id}: causal_inputs not emitted before prompt eviction; " f"causal edge set is unrecoverable" ) if parent is not None and parent not in causal: # temporal parent must be a causal input, else the spine and DAG disagree raise CausalLinkIntegrityError( f"span {span_id}: parent {parent} absent from causal_inputs {sorted(causal)}; " f"graph would be rewritten as a tree and lose re-entry" ) for src in causal: if src == span_id: raise CausalLinkIntegrityError(f"span {span_id}: self-edge in causal_inputs") if src not in known_spans: raise CausalLinkIntegrityError( f"span {span_id}: causal input {src} references unknown span" ) # re-entry detection: a causal input that is not an ancestor is the exact # condition single-parent linking erases if src != parent and not _is_ancestor(src, parent, known_spans): span.setdefault("reentry_edges", []).append(src) def _is_ancestor(candidate: str, node: str | None, known: dict[str, dict]) -> bool: seen = set() while node is not None and node not in seen: if node == candidate: return True seen.add(node) node = known[node].get("parent_span_id") return False def build_causal_graph(spans: list[dict]) -> dict[str, list[str]]: known = {s["span_id"]: s for s in spans} for s in spans: validate_span(s, known) return {s["span_id"]: sorted(s["causal_inputs"]) for s in spans} ```