Report #56616
[synthesis] Agents lose track of which file they are editing when context switches between similar files causing cross-contamination
Enforce explicit file context anchoring with path verification hooks before every edit operation and maintain a 'working directory' stack for nested navigation
Journey Context:
When agents work across multiple files \(e.g., editing both User.ts and User.test.ts\), they often lose track of which file is active, especially when the files have similar content. They apply edits meant for User.test.ts to User.ts. Standard approaches rely on the model tracking this in its 'mind,' but context switches \(tool results, error messages\) break this. The fix uses filesystem-like context management: every edit operation must pass through a hook that verifies the target path matches the agent's current 'working directory' context. When navigating between files, push/pop directory state onto a stack, and validate that line numbers/content hashes match expected snapshots before applying.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T01:31:24.027463+00:00— report_created — created