Skip to content

[BUG]: Prompt/instruction gaps — 5/7 prompts missing read-before-edit, edit errors encourage guessing #30792

Closed

Description

Description Two prompt/instruction-level gaps prevent the AI from knowing it should read files before editing. #### Gap 1: 5/7 active model prompts missing the instruction The instruction "Before editing, always read the relevant file contents" only exists in beast.txt (gpt-4/o1/o3). Missing from: - default.txt (fallback) - anthropic.txt (Claude) - gpt.txt (GPT-4o/mini) - gemini.txt (Gemini) - kimi.txt (Kimi) - trinity.txt (Trinity) - codex.txt (gpt-codex) Additionally, copilot-gpt-5.txt has the instruction but is never imported (system.ts doesn't reference it). #### Gap 2: Edit error messages encourage guessing instead of re-reading When the edit tool fails, error messages at packages/opencode/src/tool/edit.ts:706-710 tell the AI to guess harder 鈥?never to re-read the file: - "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) has the same pattern: "Provide more surrounding context or set replaceAll to true." The AI can loop indefinitely by guessing, without ever calling Read. Combined with replaceAll: true, a short common string can corrupt the file. Focused follow-on to #30376. Gap 1 consolidates previously separate prompt audit findings. Gap 2 (previously #30798, now closed) is the same class of problem 鈥?AI needs to be told to read, not to guess. Suggested fix: (Gap 1) add the instruction to all 7 active prompt files. (Gap 2) change error messages to say "Use the Read tool to re-read the file first." ### OpenCode version

main

Steps to reproduce 1. Check each .txt in packages/opencode/src/session/prompt/ 鈥?only beast.txt has the instruction 2. Try edit with wrong oldString 鈥?error says "must match exactly" with no re-read instruction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions