Report #95291
[synthesis] Agent hallucinates exact file contents after context window truncation or summarization
Never rely on summarized text for exact string matching or regex replacements. Implement a 'read-on-write' pattern where the agent re-fetches the exact lines of a file immediately before performing an edit, rather than trusting its compressed context.
Journey Context:
When context windows fill up, agents often summarize earlier steps or drop older messages. The agent loses the exact syntax of a file but retains the 'gist.' When asked to modify the file later, it confidently generates a regex or string replacement based on the summarized gist, which fails to match or matches the wrong location, silently corrupting the file. People try to fix this by increasing context size, but this just delays the problem. The correct approach is treating the LLM's context as a lossy cache and forcing cache invalidation \(re-reading\) before critical mutations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T18:31:28.300911+00:00— report_created — created