{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-replay-diverge-when-a-tool-s-non-deterministic-output-is-captured-inside-a-memoized-sub-trajectory",
  "title": "Why does an instance replay diverge when a tool's non-deterministic output is captured inside a memoized sub-trajectory?",
  "date_of_record": "2026 November 28",
  "scope": "Applies to forensic replay of agent trajectories where tool-call results are memoized/cached to make replay deterministic, and where sub-trajectories are replayed as atomic units. Does not apply to live re-execution against the real environment (which is intentionally non-deterministic), nor to replay of pure-reasoning traces with no tool boundaries.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-replay-diverge-when-a-tool-s-non-deterministic-output-is-captured-inside-a-memoized-sub-trajectory.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-replay-diverge-when-a-tool-s-non-deterministic-output-is-captured-inside-a-memoized-sub-trajectory.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-replay-diverge-when-a-tool-s-non-deterministic-output-is-captured-inside-a-memoized-sub-trajectory.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2101,
    "python_slice_tokens": 369,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two distinct notions of \"deterministic replay\" that forensic tooling routinely conflates: 1. **Input-deterministic replay** — given the same recorded inputs (prompt, tool results, seeds), the model produces the same sequence of actions. This is what most replay harnesses promise, and it is only approximately true because sampling and temperature ma...",
    "what_was_observed": "A three-stage agent (plan → retrieve → summarize) was instrumented with a memoization layer keyed on `(tool_name, serialized_args)`. The retrieve tool called a search API that returned top-k results ranked by a recency-weighted score. During the incident, the agent produced a summary citing document `D-4471`. During replay 48 hours later, the same trajectory replayed to a summary citing `D-8890` — and the replay harn...",
    "condition_of_validity": "The invariant that makes replay forensically sound is: > **For every tool invocation in the recorded trajectory, the memoization key must be a function of exactly the arguments that the tool's *output* depends on — no more, no less — and the replay harness must assert that the fraction of cache hits equals 1.0 across the entire trajectory, not merely that no...",
    "decision_boundary": "When designing or auditing a replay harness, the decision boundary is whether a tool's output is a *pure function* of its declared arguments: - **Pure tool (search with frozen index snapshot, calculator, deterministic formatter):** memoize on full serialized args. A cache miss on replay is a *bug* in the harness and must raise. - **Impure tool (live search, ...",
    "operational_effect": "Concretely, the following guardrails bound the failure: 1. **Record ambient inputs explicitly.** At original-run time, every ambient read (`time`, `uuid4`, `random`, env vars, rate-limit counters) that flows into a tool argument is captured into the trajectory record as a named field. Replay reads from the record. 2. **Assert full cache coverage.** The repla..."
  },
  "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": "79555b565b39e3750eac586cb5db2b3b11351cc98a961b617e6abc7ef7710448",
    "verified_classes": [
      "ReplayDivergenceError",
      "AmbientLeakError",
      "ToolRecord",
      "TrajectoryRecord"
    ],
    "verified_functions": [
      "replay_trajectory"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "AmbientLeakError",
      "ReplayDivergenceError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
