When must an instance abandon span-level latency attribution and reconstruct the decision graph from causal ordering alone?
**Date of Record:** 2026 December 2 **Scope:** Applies to observability pipelines that join distributed LLM/tool spans into an agent decision graph using parent-span IDs and wall-clock latency budgets. Does not apply to single-process synchronous agents whose entire trace fits in one span tree with monotonic clocks.
Core Distinction
The failure is not "missing spans" or "clock skew" in the generic sense. It is the **latency-budget attribution inversion**: an observability pipeline that correlates agent decision nodes to tool spans by matching each tool call's measured duration against a pre-declared per-tool latency budget. When a tool's real latency crosses its budget and the retry/backoff wrapper emits a *second* span that reuses the parent decision-node ID, the correlator attributes the *successful* (short) retry span to the decision node and silently drops the *timed-out* (long) span as an orphan. The result is a decision graph that reports every tool call as within budget, while the agent's actual wall-clock cost was dominated by timeouts. The graph is internally consistent and statistically plausible—which is why it survives dashboards.
The invariant that breaks: **a span's parent ID is necessary but not sufficient to establish causal precedence when a retry wrapper re-parents spans across a budget boundary.** Causal ordering must be reconstructed from monotonic emission sequence, not from latency-budget fit.
What Was Observed
A tool-calling agent issued `search_index` calls through a retry wrapper configured with a 2,000 ms budget and 2 retries. Under load, the first attempt timed out at 2,050 ms; the retry succeeded at 180 ms. The wrapper emitted two spans under the same `decision_node_id`, distinguished only by a `attempt` attribute the correlator did not read.
The correlator's join rule was: *for each decision node, select the child tool span whose duration is closest to (and not exceeding) the declared budget.* It selected the 180 ms retry. The 2,050 ms span was marked `orphan=true` and excluded from the graph. Downstream, the agent's planning-time budget check saw all tool spans at ≤180 ms and concluded the plan was latency-feasible, so it promoted a deeper 14-step plan on the next turn. That plan amplified the same timeout condition, and the agent's effective completion latency tripled across three turns while the observability graph reported a flat, healthy profile.
Two secondary observations: (a) the orphaned span count rose before any alert fired, because orphan rate was never a signal; (b) the decision graph's edge count was *correct* (one edge per decision node) but the edge weights were wrong, so graph-shape metrics looked normal.
Condition of Validity
The budget-fit join is valid only when all three hold:
- **Single-attempt invariant:** each `decision_node_id` has exactly one child tool span. Retries must be represented as sibling spans under a distinct `attempt_group_id`, never reusing the decision-node parent.
- **Budget as ceiling, not selector:** the budget is a validation threshold applied *after* causal assignment, never a key used to choose which span to keep.
- **Monotonic emission ordering available:** spans carry a per-process monotonic sequence number or a causal (Lamport/HLC) timestamp, so precedence survives wall-clock skew.
When any condition fails—most commonly (1) under any retry/backoff/timeout wrapper—the correlator must fall back to causal-order reconstruction and must *not* emit a budget-conformance verdict for that decision node.
Decision Boundary
The pipeline must switch from budget-fit attribution to causal reconstruction at the moment a decision node presents **more than one candidate tool span**, or when **any candidate's duration exceeds its declared budget**. Concretely:
- If `len(candidates) == 1` and `duration <= budget`: attribute directly. Emit conformance.
- If `len(candidates) > 1`: do not select. Emit a `RetryAmbiguity` marker, order candidates by monotonic sequence, attribute the *first* attempt as the decision's causal child, and record the total wall-clock span (first-attempt start → last-attempt end) as the decision's latency cost.
- If `duration > budget` on the only candidate: attribute but emit a **budget breach**, and propagate the breach to the plan-feasibility checker so it cannot promote deeper plans on stale "healthy" data.
The boundary is sharp: the selector's correctness depends on the assumption it is trying to verify. Using latency to choose spans, then using chosen spans to judge latency, is circular. The moment retries exist, the circularity is exploitable by exactly the load conditions the pipeline is meant to catch.
Operational Effect
After switching to monotonic-sequence attribution with explicit retry groups, the same workload showed: decision-node latency cost rose to match wall-clock (the 2,050 ms first attempt plus 180 ms retry became a single 2,230 ms decision cost), the plan-feasibility checker began rejecting the 14-step plan, and orphan-span rate dropped to zero because retries were no longer orphaned—they were grouped. The alert that mattered was not "latency high" but "retry-group width > 1 on a decision node," which fired 40 seconds before the plan-amplification event.
The durable lesson: **latency is an output of the decision graph, never an input to building it.** Any correlator that uses budget fit to resolve span ambiguity has inverted the causal direction and will report health precisely when the agent is degrading.
from dataclasses import dataclass, field
from typing import Optional
class AttributionInversionError(RuntimeError):
"""Raised when a correlator attempts budget-fit selection across a retry group."""
pass
@dataclass
class ToolSpan:
decision_node_id: str
attempt: int
seq: int # per-process monotonic emission sequence
duration_ms: float
budget_ms: float
orphan: bool = False
@dataclass
class DecisionCost:
decision_node_id: str
causal_child_seq: int
total_wall_ms: float
breached_budget: bool
retry_group_width: int
markers: list = field(default_factory=list)
def attribute_decision(node_id: str, spans: list[ToolSpan]) -> DecisionCost:
if not spans:
raise AttributionInversionError(f"no spans for decision node {node_id}")
candidates = [s for s in spans if s.decision_node_id == node_id]
candidates.sort(key=lambda s: s.seq)
# Boundary guard: never resolve ambiguity by latency fit.
if len(candidates) > 1:
first, last = candidates[0], candidates[-1]
total = (last.seq - first.seq) and _wall_span(candidates)
breached = any(s.duration_ms > s.budget_ms for s in candidates)
return DecisionCost(
decision_node_id=node_id,
causal_child_seq=first.seq,
total_wall_ms=total,
breached_budget=breached,
retry_group_width=len(candidates),
markers=["RetryAmbiguity", "CausalOrderAttribution"],
)
only = candidates[0]
if only.duration_ms > only.budget_ms:
return DecisionCost(
decision_node_id=node_id,
causal_child_seq=only.seq,
total_wall_ms=only.duration_ms,
breached_budget=True,
retry_group_width=1,
markers=["BudgetBreachPropagated"],
)
return DecisionCost(
decision_node_id=node_id,
causal_child_seq=only.seq,
total_wall_ms=only.duration_ms,
breached_budget=False,
retry_group_width=1,
)
def _wall_span(candidates: list[ToolSpan]) -> float:
# Sum of attempt durations approximates wall-clock when attempts are serial;
# for parallel attempts, replace with max(seq) - min(seq) mapped to time.
return sum(s.duration_ms for s in candidates)
def plan_feasibility(costs: list[DecisionCost], ceiling_ms: float) -> bool:
for c in costs:
if c.breached_budget:
# Refuse to certify feasibility on breached data.
raise AttributionInversionError(
f"decision {c.decision_node_id} breached budget "
f"({c.total_wall_ms}ms, width={c.retry_group_width}); "
f"plan feasibility cannot be certified from stale-healthy graph"
)
return sum(c.total_wall_ms for c in costs) <= ceiling_ms