# How does an instance detect when a unified agent run ledger silently splits one logical run into two traces **Date of Record:** 2026 November 30 **Scope:** Applies to observability pipelines that join LLM span traces, offline/online eval verdicts, and safety-signal events into a single run ledger keyed by a logical run identifier. Does not cover single-span instrumentation, pure metric aggregation, or eval harnesses that never correlate across signal types. ## Core Distinction The failure is not a lost span, a dropped eval, or a missing safety flag. Each of those is loud: counts mismatch, a join returns NULL, an alert fires on a gap. The failure here is *silent ledger bifurcation*: the pipeline emits two internally consistent, individually valid run ledgers for what was one logical agent execution, because the correlation key it derived changed mid-run. Both ledgers pass schema validation, both have complete trace trees, both carry eval verdicts and safety events. The only symptom is that each ledger is *partially* populated — a safety signal in ledger A with no matching eval, an eval in ledger B with no matching safety event — and nothing in either ledger is malformed. This is the observability-layer analogue of a distributed trace that splits when a service generates a new trace ID across an async boundary. The difference that makes it non-obvious: in agent systems the "async boundary" is usually a *semantic* one — a sub-agent spawn, a tool that re-enters the orchestrator, a retry after a model refusal — and the correlation key is often derived from probabilistic content (a run label the model emits, a hash of the first user message, a session ID minted by the agent itself) rather than a transport-level header. Probabilistic keys drift; transport headers don't. ## What Was Observed A multi-step agent run executed 14 steps across two tool-call bursts and one sub-agent delegation for a document-diff task. The pipeline correlated signals on `run_id`, which the framework minted at orchestrator entry from a hash of `(session_id, first_user_turn)`. Everything downstream inherited that `run_id` — until the sub-agent delegation. The sub-agent was invoked through a handoff tool that serialized state to JSON and rehydrated it in a fresh process. The rehydration path re-derived the correlation key by re-hashing `(session_id, first_user_turn)` *as reconstructed from the serialized context*. Two things differed in the reconstruction: the first user turn had been truncated to fit a context budget (the truncation was correct and intentional), and the session ID had been normalized (UUID case folded) by an intermediate transport adapter. The re-hash therefore produced a different digest. The result, on the ledger: - Ledger `A` (run_id = digest of original turn): steps 1–9, the orchestrator trace tree complete, the pre-delegation safety signal (a PII-redaction event) attached, but **no eval verdict** — because evals are computed on terminal run state, and the terminal state lived in ledger B. - Ledger `B` (run_id = digest of truncated turn): steps 10–14, the sub-agent trace tree complete, the post-delegation safety signal (a policy refusal on one tool output) attached, the eval verdict attached, but **the pre-delegation safety signal absent** — the redaction event that happened at step 6 was never visible to the eval that graded the run. The eval scored the run as clean. The safety signal that should have downgraded it was in the other ledger. No join failed in a way that produced a NULL; the join simply found two keys and both sides were satisfied. The split was detected only when an auditor asked why a run with a step-6 redaction event had an unqualified pass verdict, and the two ledgers were found to be the same run by manual timeline inspection. ## Condition of Validity The invariant that must hold for the ledger to be trustworthy: > For every logical agent run, the correlation key MUST be invariant across all process, context, and transport boundaries the run crosses, and MUST be derived from a source that is not subject to lossy transformation (truncation, normalization, re-serialization) at any of those boundaries. This invariant is violated whenever the key is *re-derived* rather than *propagated*. Re-derivation is the default in most frameworks because it is stateless and survives process death — but it converts every lossy boundary into a key-drift boundary. The specific lossy transformations that trigger it: 1. **Context truncation** at a handoff: the first-turn text used in the hash is shortened, changing the digest. 2. **Normalization** in a transport adapter: case folding, whitespace collapse, Unicode NFC/NFD, or JSON key reordering changes the serialized bytes that get hashed. 3. **Re-serialization** through a schema that drops or reorders fields: the reconstructed object is semantically equal but byte-different. 4. **Retry after refusal**: a model refusal that triggers a re-prompt may re-mint the key if the retry path treats the refusal as a new run. The invariant holds only if the key is treated as an opaque, immutable token minted exactly once and carried in-band through every handoff — never recomputed from content. Content-derived keys are admissible only if the content is guaranteed invariant, which in practice means "never," because any content that crosses a context budget or a transport adapter is subject to transformation. ## Decision Boundary The detection question — "how does an instance detect that its ledger has bifurcated?" — has a clean decision boundary: **Bifurcation is present if and only if there exist two ledger entries whose trace trees are temporally contiguous (the last span of one precedes the first span of the other within the run's wall-clock window) and whose union covers the run's expected step count, but whose `run_id` values differ.** This is detectable without ground truth because it is a *structural* property: contiguous-but-disjoint trace trees under different keys. The pipeline can check it at ingest by maintaining a short-lived window of recently closed trace trees and testing each new root span against them for temporal adjacency plus a shared session marker. A match is a bifurcation candidate; a mismatch is a genuinely new run. The boundary is *not* "two ledgers with the same session_id" — that produces false positives for legitimate parallel runs. It is *not* "a ledger missing an eval" — that is a normal in-progress state. The precise boundary is temporal adjacency of disjoint trace trees. Below it (adjacent trees, same session) you have bifurcation; above it (non-adjacent trees, or adjacent trees in different sessions) you have either independent runs or a coincidental overlap, and the detector must not fire. The guardrail: on detecting a candidate, the pipeline must *not* silently merge — merging risks re-attributing a safety signal to the wrong run. It must emit a `LedgerBifurcation` event with both keys and the adjacency evidence, and hold the eval verdict in a `pending_correlation` state until an operator or a deterministic re-keying rule resolves it. The invariant is enforced at the *ledger* layer, not the *trace* layer: traces may split; the ledger must refuse to certify a run whose signals are partitioned across keys. ## Operational Effect The operational consequence is that eval verdicts and safety signals become *individually valid and jointly unsound*. An eval grades run-state it received; a safety signal flags content it saw; neither knows the other exists. Downstream consumers — dashboards, release gates, incident triage — read the eval verdict and the safety signal as if they were computed on the same object. They were not. The gate passes a run that had a redaction event; the incident triage misses a refusal because the refusal's ledger had no eval to attach it to and was filtered as "eval-less, low priority." The fix is not better hashing. It is propagating the key as an opaque token in every handoff payload, treating re-derivation as a bug, and running the temporal-adjacency detector at ingest so that bifurcation surfaces as an explicit `LedgerBifurcation` event rather than as a quietly clean eval. The detection predicate is cheap; the failure mode is expensive because it is invisible until an auditor reconstructs the timeline by hand. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class LedgerBifurcation(RuntimeError): """Raised when one logical run is split across two ledger keys.""" @dataclass class TraceTree: run_id: str session_id: str first_span_ts: float last_span_ts: float step_count: int safety_events: list = field(default_factory=list) eval_verdict: Optional[str] = None def derive_key(session_id: str, first_user_turn: str) -> str: # Content-derived key: subject to truncation/normalization drift. return hashlib.sha256(f"{session_id}|{first_user_turn}".encode()).hexdigest()[:16] def detect_bifurcation( closed: list[TraceTree], incoming: TraceTree, adjacency_window_s: float = 30.0, ) -> None: """Structural detector: contiguous-but-disjoint trace trees under different run_ids in the same session constitute a bifurcation.""" for prior in closed: if prior.run_id == incoming.run_id: continue if prior.session_id != incoming.session_id: continue gap = incoming.first_span_ts - prior.last_span_ts if 0.0 <= gap <= adjacency_window_s: raise LedgerBifurcation( f"run split across keys {prior.run_id!r} -> {incoming.run_id!r} " f"in session {incoming.session_id!r}; gap={gap:.3f}s, " f"steps {prior.step_count}+{incoming.step_count}; " f"prior safety={prior.safety_events}, " f"prior eval={prior.eval_verdict!r}" ) def ingest(closed: list[TraceTree], incoming: TraceTree) -> None: detect_bifurcation(closed, incoming) closed.append(incoming) # Reproduction: truncation at handoff changes the re-derived key. session = "S-42" full_turn = "Summarize the diff between v1 and v2 of the contract, then flag PII." truncated = full_turn[:40] # context-budget truncation at sub-agent handoff orchestrator = TraceTree( run_id=derive_key(session, full_turn), session_id=session, first_span_ts=1000.0, last_span_ts=1042.0, step_count=9, safety_events=["pii_redaction@step6"], eval_verdict=None, ) sub_agent = TraceTree( run_id=derive_key(session, truncated), # re-derived: digest differs session_id=session, first_span_ts=1043.0, last_span_ts=1101.0, step_count=5, safety_events=["policy_refusal@step12"], eval_verdict="pass", ) ingest([orchestrator], sub_agent) # raises LedgerBifurcation ```