Report #61662
[frontier] Agent regenerates entire files causing token overflow and hallucination drift
Enforce unified-diff output format for all code edits; validate patches with \`patch --dry-run\` before application and reject any non-diff response
Journey Context:
Whole-file rewrite exhausts context windows on large codebases and introduces 'hallucination drift' where unchanged lines are mutated. Aider and Devin proved that agents emitting standard unified diffs \(with 3-line context\) reduce token usage by 60-80% and allow deterministic validation via patch\(1\). The anti-pattern is 'search/replace blocks' which break on indentation changes; unified diffs are robust to line offsets when using \`patch --fuzz\`. This requires adding a lint step that rejects non-diff outputs before any file write.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T09:59:11.951541+00:00— report_created — created