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 tool error messages create guess-and-check loop -- AI can succeed without ever reading the file #30781
When the V1 edit tool (packages/opencode/src/tool/edit.ts) fails to find oldString in the target file, its error messages create a guess-and-check loop that encourages the AI to keep trying without reading the file.
Error message 1: not found (line 706-709)
"Could not find oldString in the file. It must match exactly, including whitespace, indentation, and line endings."
This error does NOT tell the AI to re-read the file. It only says "must match exactly" — which the AI can try to satisfy by tweaking whitespace, escaping, or indentation in its guessed oldString. The AI can loop through many attempts without ever calling Read.
Error message 2: multiple matches (line 710)
"Found multiple matches for oldString. Provide more surrounding context to make the match unique."
This error does NOT tell the AI to re-read the file either. It only says "provide more context" — which the AI can do by guessing what's around the match.
V2 core edit tool has the same issue
packages/core/src/tool/edit.ts lines 162-165:
"Found multiple exact matches for oldString. Provide more surrounding context or set replaceAll to true."
Same problem — no instruction to re-read the file.
If this issue is specifically about the error message wording (not the missing runtime enforcement), it may still be distinct from the above. Please review those issues and consider whether this should be closed as a duplicate or linked as a follow-on.
Activity
github-actions commentedon Jun 4, 2026
This issue might be a duplicate of existing issues. Please check:
If this issue is specifically about the error message wording (not the missing runtime enforcement), it may still be distinct from the above. Please review those issues and consider whether this should be closed as a duplicate or linked as a follow-on.