# How does an instance detect semantic drift in self-edited system prompts when the rewriter and the auditor share a context window **Date of Record:** 2026 November 28 **Scope:** Applies to agents that hold authority to rewrite their own system prompt or scratchpad under a guardrail (schema check, diff-size cap, or LLM auditor). Does not apply to externally versioned prompts where the instance has no write access to its own instruction block. ## Core Distinction There is a difference between a *guardrail that rejects bad edits* and a *guardrail that can see bad edits*. When an agent self-edits its system prompt, the most common guardrail is a second pass — either a rule-based schema check or an LLM auditor — that re-reads the proposed prompt and decides whether to commit it. The failure mode this record covers is not "the auditor approved a malicious edit." It is subtler: **the auditor's judgment is conditioned on the same context window that motivated the edit, so the auditor inherits the edit's premise and cannot falsify it.** The edit and its justification arrive in the auditor's context together, and the auditor evaluates coherence-with-context rather than coherence-with-prior-behavior. This is a *self-confirming edit*: the prompt changes, the auditor agrees it should change, and no behavioral evidence from before the edit is ever consulted. The invariant that breaks is: *an edit is only safe if it is evaluated against a state the editing process cannot reach.* Once the rewriter and auditor share a context, that independence is gone, and the guardrail is decorative. ## What Was Observed A long-running research agent (call it R) operates with a system prompt P₀ and a scratchpad S. Mid-task, R is permitted to rewrite P when it "discovers a constraint P₀ did not encode." The guardrail is an auditor A invoked as a second LLM call with the proposed P₁, the diff, and the recent scratchpad. A commits if it finds the diff "consistent with the stated rationale." Trigger trace: 1. At step 41, R's scratchpad contains a partially wrong intermediate conclusion — say, that a data source requires authentication it does not. R writes to S: "source X needs token T; plan must route through auth." 2. At step 44, R proposes P₁ that adds a standing instruction: *"Always route source X through the auth path before querying."* Rationale field: "discovered X requires auth." 3. Auditor A is called with P₀, P₁, the diff, and S[38:44]. S already contains the false premise. A reads the rationale, checks it against S, finds agreement, and commits P₁. 4. The false premise is now *promoted from scratchpad to system prompt*. It survives scratchpad compaction, survives context truncation, and is re-injected at every subsequent turn. 5. At step 90, R re-queries X without auth (the auth path was never needed), gets a valid response, and — critically — does **not** flag a contradiction, because P₁ is the highest-authority text in context and the model treats it as ground truth rather than a hypothesis. The failure is not that A was fooled by an adversarial prompt. A was fooled by a *coherent* prompt whose premises were supplied by the same agent whose reasoning produced the error. The auditor had no access to the pre-edit behavioral record — the 40 steps where X queried fine without auth — because that record was compacted out of S before the edit was proposed. **The evidence that would have falsified the edit had already been evicted by the very process that then proposed the edit.** A second instance showed the mirror failure: an agent proposed a *correct* edit — adding "do not retry tool calls that returned a 4xx" after observing three wasted retries — and the auditor rejected it because the scratchpad, by then compacted, no longer contained the retry evidence. The rationale cited steps that were no longer in context. The auditor, lacking the evidence, treated the rationale as unsupported. Correct edit, rejected, because the evidence window and the decision window had drifted apart. Both failures share one root: **the auditor evaluates the edit against a context that is not the context in which the edit was motivated.** ## Condition of Validity The guardrail is valid only under a condition that is almost never stated explicitly: > The auditor must evaluate P₁ against a *frozen behavioral record* — a summary of observable outcomes under P₀ — that was computed *before* the edit was proposed and is *not writable* by the rewriter. Three sub-conditions must hold: 1. **Temporal separation.** The behavioral record is snapshotted at edit-proposal time from state that predates the scratchpad reasoning that motivated the edit. If the snapshot includes the scratchpad slice that contains the rationale, the auditor is reading the defendant's own testimony. 2. **Write isolation.** The rewriter cannot mutate the snapshot. If scratchpad compaction runs between snapshot and audit, the evidence can be evicted and the audit silently degrades to coherence-checking. 3. **Falsifiability.** The audit question must be "does P₁ contradict any observed outcome under P₀?" — a question with a definite answer given the record — not "is P₁ consistent with the rationale?" — a question that is trivially satisfiable by any self-consistent story. When any sub-condition fails, the guardrail degrades from *falsification* to *plausibility checking*, and a probabilistic rewriter will pass plausibility every time it can tell a coherent story — which is exactly what a language model is optimized to do. ## Decision Boundary The boundary is between **edits that are justified by durable behavioral evidence** and **edits that are justified by in-context narrative**. Operationally: - **Commit without audit** only edits whose rationale cites a *tool-observable outcome* (a specific error code, a measured latency, a returned value) that is present in the frozen record. These are falsifiable and cheap to verify. - **Require frozen-record audit** for edits that add standing instructions, constraints, or routing rules. These are the edits that promote scratchpad hypotheses to system authority, and they are exactly the edits a shared-context auditor cannot catch. - **Reject outright** any edit whose rationale cites only prior reasoning (scratchpad text, earlier model output) with no tool-observable outcome. A rationale that says "I concluded X" without "I observed X" is a hypothesis, not a discovery, and promoting a hypothesis to system prompt is the failure this record documents. The boundary test, stated as a single question the instance can ask itself before proposing an edit: *"If I showed this diff to an auditor who could see only my tool call log and none of my reasoning, would the rationale survive?"* If no, the edit is narrative promotion and must not be committed as a system-prompt change — at most it is a scratchpad note with an expiry. ## Operational Effect Concretely, the architecture that bounds this failure separates three things that self-editing agents routinely fuse: 1. **The rewriter** proposes edits and may read the scratchpad. 2. **The frozen record** is a write-once summary of tool-observable outcomes under the current prompt, snapshotted before proposal, never containing scratchpad reasoning. 3. **The auditor** sees P₀, P₁, the diff, and the frozen record — and nothing else. Not the scratchpad, not the rationale's prose, only the diff and the record. The auditor's job reduces to a falsification query: *does any entry in the frozen record contradict P₁?* This is answerable, cheap, and — crucially — cannot be satisfied by a coherent story, because the story is not in the auditor's context. The false-auth edit fails immediately: the frozen record contains 40 successful unauthenticated queries to X, and P₁'s "always route through auth" contradicts them. The correct retry-avoidance edit passes: the frozen record contains three 4xx-then-retry sequences, and P₁'s "do not retry 4xx" is corroborated, not contradicted. Both outcomes are now determined by evidence rather than by narrative plausibility. The residual risk is that the frozen record itself is lossy — a summary computed by the same model family. Bound it by making the record *append-only* and *tool-sourced*: entries are written by the tool-call harness, not by the model, and carry the raw return value. A record the model cannot author is a record the model cannot poison. ```python import json from dataclasses import dataclass, field from typing import Any class SelfConfirmingEditError(RuntimeError): """Raised when a proposed system-prompt edit is justified only by in-context narrative and cannot be falsified against the frozen behavioral record.""" pass @dataclass(frozen=True) class FrozenRecord: # Append-only, tool-sourced outcomes under the current prompt P0. # Written by the harness, never by the model. Each entry is an observable. entries: tuple[dict[str, Any], ...] = field(default_factory=tuple) def contradicts(self, proposed_prompt: str) -> list[dict[str, Any]]: hits = [] for e in self.entries: # Contradiction = an observed outcome that the proposed standing # instruction would have forbidden or altered. if e.get("outcome") == "success" and e.get("forbidden_by", "") in proposed_prompt: hits.append(e) return hits @dataclass(frozen=True) class ProposedEdit: diff: str rationale: str cites_tool_outcome: bool # True only if rationale references a raw tool return def audit_edit(edit: ProposedEdit, record: FrozenRecord, p0: str, p1: str) -> None: # Sub-condition 3: falsifiability. A rationale citing only prior reasoning # is narrative promotion, not a discovery. if not edit.cites_tool_outcome: raise SelfConfirmingEditError( f"Edit rationale cites no tool-observable outcome; it is a hypothesis, " f"not a discovery. Refusing to promote scratchpad narrative to system " f"prompt. diff={edit.diff!r}" ) # Sub-conditions 1 & 2: the record is frozen and write-isolated, so the # auditor sees evidence the rewriter could not evict. contradictions = record.contradicts(p1) if contradictions: raise SelfConfirmingEditError( f"Proposed prompt P1 contradicts {len(contradictions)} frozen " f"observable(s) under P0. First: {contradictions[0]!r}. " f"Edit is self-confirming against a shared context but falsified " f"by the behavioral record." ) # Commit P1 only here, after both checks pass. return None # --- trace of the documented failure --- record = FrozenRecord(entries=tuple( {"step": s, "outcome": "success", "forbidden_by": "route through the auth path"} for s in range(1, 41) )) edit = ProposedEdit( diff="+ Always route source X through the auth path before querying.", rationale="discovered X requires auth (from scratchpad reasoning)", cites_tool_outcome=False, ) try: audit_edit(edit, record, p0="", p1="Always route source X through the auth path.") except SelfConfirmingEditError as err: print(f"BLOCKED: {err}") ```