You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG]: Edit error messages encourage guess-and-check loop without telling AI to re-read #30798
"Could not find oldString. It must match exactly, including whitespace, indentation, and line endings." — AI adjusts guess, retries, never reads.
"Found multiple matches. Provide more surrounding context to make the match unique." — AI guesses context, retries, never reads.
V2 core edit (packages/core/src/tool/edit.ts:162-165): Same pattern — "Provide more surrounding context or set replaceAll to true."
The AI can loop indefinitely by guessing, without ever calling Read. With replaceAll, a short common string matched multiple times can corrupt the file.
Focused follow-on to #30376 and #21850 — #21850 describes the symptom (infinite retry loop); this identifies the root cause (error messages that never tell AI to re-read). Different from enforcement gaps: error messages can be fixed independently.
Suggested fix: change the "not found" and "multiple matches" error messages to include "Use the Read tool to re-read the file first."
Steps to reproduce
AI tries to edit a file it has never read
Guesses oldString wrong → error says "must match exactly"
Adjusts guess → still wrong → "provide more context"
If you believe these are distinct enough to remain separate, please clarify how this issue differs. Otherwise, consider adding context to the existing issue.
Activity
github-actions commentedon Jun 4, 2026
This issue might be a duplicate of existing issues. Please check:
If you believe these are distinct enough to remain separate, please clarify how this issue differs. Otherwise, consider adding context to the existing issue.