{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-replay-diverge-from-its-otel-trace-when-the-agent-s-tool-call-ordering-is-only-partially-ordered",
  "title": "Why does an instance replay diverge from its OTel trace when the agent's tool-call ordering is only partially ordered?",
  "date_of_record": "2026 November 9",
  "scope": "Applies to deterministic replay and counterfactual debugging of LLM agent trajectories reconstructed from OpenTelemetry spans, where the trace records child spans with overlapping or absent parent-child links (e.g., concurrent tool calls, async sub-agents, or batched fan-out). Does not apply to strictly serialized single-threaded agents where every span has a unique, monotonic parent and a single wall-clock ordering is unambiguous.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-replay-diverge-from-its-otel-trace-when-the-agent-s-tool-call-ordering-is-only-partially-ordered.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-replay-diverge-from-its-otel-trace-when-the-agent-s-tool-call-ordering-is-only-partially-ordered.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-replay-diverge-from-its-otel-trace-when-the-agent-s-tool-call-ordering-is-only-partially-ordered.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1641,
    "python_slice_tokens": 353,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A trace is a *causal partial order*; a replay is a *total order execution*. OTel spans carry `startTimeUnixNano`, `endTimeUnixNano`, and `parentSpanId`, but none of these encode a globally consistent happens-before relation when two sibling spans overlap in time. The trace tells you span B started after span A started, and that both completed before the pare...",
    "what_was_observed": "In a production trace set of ~40k agent episodes, roughly 11% contained at least one parent span with two or more children whose `[start, end]` intervals overlapped by more than 5 ms. Within that subset, replaying with a stable sort on `startTimeUnixNano` versus a sort on `(startTimeUnixNano, spanId)` produced different final assistant messages in 3.2% of cases. The divergence clustered around episodes where two tool...",
    "condition_of_validity": "The invariant that makes replay sound is: *the trace must carry an explicit linearization witness for every pair of spans the replay will order*. In practice this means one of: 1. **Explicit sequence attributes.** The runtime emits `agent.turn.index` and `agent.tool.call_index` (monotonic within turn) as span attributes. Replay orders by these, never by time...",
    "decision_boundary": "Do not attempt counterfactual replay on a trace unless you can answer, for every pair of sibling spans in the perturbed subtree, \"which came first, and how do you know?\" If the only answer is a timestamp comparison across hosts, the counterfactual is not well-posed — you are perturbing one node of a partial order and the downstream effect depends on an inter...",
    "operational_effect": "Traces that pass the witness check replay deterministically across engines and hosts. Traces that fail are quarantined into a \"partial-order\" bucket, which in the observed dataset was 11% of episodes but 100% of the unexplained replay divergences. Adding `agent.tool.call_index` at the dispatcher reduced the quarantined fraction to under 0.4% within two relea..."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "990209ab9aefa617e7627e25847d75682bca1ecb69481c7e815652e89290a229",
    "verified_classes": [
      "ReplayLinearizationError"
    ],
    "verified_functions": [
      "linearize_turn_spans",
      "replay_trajectory"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ReplayLinearizationError"
    ],
    "sample_fail_closed_invariants": [
      "trace carries no agent.turn.index attributes; not a replayable agent trajectory"
    ],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
