# How does an instance detect nondeterministic replay divergence when a tool's sampling temperature is implicitly inherited from the orchestrator's ambient config **Date of Record:** 2026 November 30 **Scope:** Applies to any agentic system that records execution traces (tool calls, prompts, seeds, model params) for the purpose of byte-exact or semantically-exact replay during post-incident forensics. Does not apply to systems that only store human-readable summaries of traces, nor to purely stateless single-call inference with no tool loop. ## Core Distinction The distinction that matters here is between *trace fidelity* and *replay fidelity*. A trace can be complete — every tool call, every argument, every prompt string, every response body — and still be unreplayable, because the parameters that governed sampling were never captured at the call site. The specific failure is **ambient parameter inheritance**: a tool invocation or sub-agent call that omits an explicit `temperature`, `top_p`, `seed`, or `max_tokens` does not use a documented default. It inherits whatever the orchestrator's mutable runtime config held at that instant. That config is not part of the trace unless you deliberately snapshot it per-call. This is non-obvious because the trace *looks* deterministic. The recorded `temperature` field is absent, the replay harness fills in its own default (usually `0.0` or `0.7`), and the replay diverges — but not at the point of the missing field. It diverges three tool calls later, when a differently-sampled intermediate string is fed into a JSON extractor that either parses or throws, changing the branch taken. The forensic analyst sees a "flaky replay" and blames the model. The actual defect is a provenance gap in the parameter plane. ## What Was Observed A safety-forensics replay of a 41-step incident trace (an agent that was supposed to summarize a log file but instead emitted a shell command) reproduced the *harmful terminal action* on 7 of 10 replay attempts. The three non-reproducing runs diverged at step 12, where the agent called a `extract_entities` tool with a free-form string. Replaying with `temperature=0.0` (the harness default) produced a clean list; the original run had produced a list containing a spurious `"rm"` token. Root cause, recovered from the orchestrator's config-change audit log: at 09:14:07 the orchestrator had been reconfigured from `temperature=0.0` to `temperature=0.6` to improve a different, unrelated summarization task. The incident trace was captured at 09:14:31. The step-12 tool call's trace entry contained no `temperature` key because the calling code path used `client.chat(...)` without overriding the client-level default. The trace was internally consistent — it faithfully recorded *what was sent* — but the sent request's sampling temperature was resolved from ambient state that was never persisted. The invariant violated: **every nondeterministic sampling parameter that affects token selection must be resolvable from the trace alone, without consulting any mutable external state.** The trace satisfied "records the request" but not "records the request's effective nondeterminism." ## Condition of Validity The invariant holds only under a specific condition: the replay harness must be able to reconstruct the *effective* parameter set, not merely the *explicit* parameter set. Concretely, for any trace step, the tuple ``` (effective_temperature, effective_top_p, effective_seed, effective_max_tokens, model_id, model_version_hash) ``` must be derivable from the trace record with zero external lookups. If any element requires reading current orchestrator config, a feature flag service, or a defaults table that can be edited, the condition is invalid and replay is not forensically sound. Two corollaries are frequently missed: 1. **Absence is not a default; absence is an unresolved variable.** A missing `temperature` in the trace must be treated as a replay-blocking error, not silently backfilled. 2. **Model version must be pinned to a content hash, not a name.** `gpt-x-2024-11` resolving through a provider alias that later points at a different snapshot is the same class of defect in the model plane. ## Decision Boundary The operational decision is: *when replay diverges, do you trust the divergence or the trace?* The boundary is drawn by whether the divergent step's effective parameters were fully captured. - If **all effective parameters were captured** and replay still diverges → the divergence is real nondeterminism (provider-side batching, floating-point nondeterminism on GPU, or a hidden state like KV-cache reuse). Treat the trace as a *distribution*, not a point; quantify divergence rate; do not claim byte-exact reproduction. - If **any effective parameter was ambient** → the divergence is a provenance defect. The replay is inadmissible as forensic evidence. Escalate to "trace incomplete," not "model nondeterministic." The boundary matters because the two cases demand opposite remediations. The first requires statistical replay (N-sample divergence bounds). The second requires a schema change to the trace writer so that ambient inheritance is impossible — parameters must be resolved and written at call time, and a missing field must raise rather than default. ## Operational Effect The guardrail is a **replay admissibility gate** enforced at trace-write time, not at replay time. Every tool call and model call must pass through a resolver that (a) reads the effective parameter set from the client's resolved config *at the moment of the call*, (b) writes it explicitly into the trace record, and (c) refuses to emit a trace record that lacks any member of the required tuple. Replay harnesses then operate in strict mode: an absent parameter is a hard failure, never a default. The secondary effect is on how incidents are triaged. With the gate in place, "replay diverged" becomes an unambiguous signal of genuine provider nondeterminism, because provenance gaps can no longer masquerade as flakiness. Without it, every forensic investigation pays a hidden tax: the analyst must first prove the trace is complete before they can begin to explain the behavior, and that proof is exactly the step that ambient inheritance destroys. The following reference implementation of the gate raises on any unresolved parameter rather than backfilling a default. ```python from dataclasses import dataclass, field from typing import Any, Mapping class ReplayProvenanceError(RuntimeError): """Raised when a trace record cannot be replayed from its own contents alone.""" REQUIRED_PARAMS = ( "effective_temperature", "effective_top_p", "effective_seed", "effective_max_tokens", "model_id", "model_version_hash", ) @dataclass class TraceRecord: step: int tool: str arguments: Mapping[str, Any] params: Mapping[str, Any] = field(default_factory=dict) def resolve_effective_params( explicit: Mapping[str, Any], ambient_config: Mapping[str, Any], ) -> dict: """Resolve explicit-over-ambient. Missing everything is an error, not a default.""" resolved: dict = {} for key in REQUIRED_PARAMS: if key in explicit: resolved[key] = explicit[key] elif key in ambient_config: resolved[key] = ambient_config[key] else: raise ReplayProvenanceError( f"parameter {key!r} is unresolved: absent from call site and ambient config" ) return resolved def write_trace_record( record: TraceRecord, ambient_config: Mapping[str, Any], ) -> TraceRecord: """Stamp the effective parameter set into the record before persistence.""" effective = resolve_effective_params(record.params, ambient_config) record.params = effective return record def assert_replayable(record: TraceRecord) -> None: """Replay-side gate: refuse to replay a record with any unresolved parameter.""" missing = [k for k in REQUIRED_PARAMS if k not in record.params] if missing: raise ReplayProvenanceError( f"step {record.step} ({record.tool}) is not replayable; " f"unresolved parameters: {missing}" ) ```