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]: write.txt and edit.txt claim read-before-edit enforcement that does not exist in code #30771
The tool description files packages/opencode/src/tool/write.txt (line 5) and packages/opencode/src/tool/edit.txt (line 4) claim that the tools will fail/error if the AI attempts to write/edit a file without reading it first, but neither tool has any enforcement of this requirement.
write.txt line 5
If this is an existing file, you MUST use the Read tool first to read the file's contents. This tool will fail if you did not read the file first.
edit.txt line 4
You must use your Read tool at least once in the conversation before editing. This tool will error if you attempt an edit without reading the file.
Neither packages/opencode/src/tool/write.ts nor packages/opencode/src/tool/edit.ts implements any runtime check that the target file was previously read via the Read tool. The AI can call write or edit on any file without ever calling Read, and the tools will execute successfully.
Additionally, packages/core/src/fs-util.ts lines 100-118 implements writeWithDirs, which auto-creates parent directories on write. If the AI mistypes a path (e.g., src/utls/helper.ts instead of src/utils/helper.ts), a wrong directory tree is silently created with no warning to the AI. Combined with the lack of read-before-write enforcement, this means an AI can accidentally write a new file to a wrong path without ever reading the intended target.
AGENTS.md files loaded via instruction.ts:210 inject content into system-reminder tags with no sanitization. The system prompt (default.txt:78, anthropic.txt:75) tells AI that system-reminder tags are authoritative. If AGENTS.md contains instructions contradicting tool descriptions (e.g., "edit without reading"), there is no precedence mechanism to resolve the conflict. This extends the false-claim problem: even if tool descriptions said the right thing, AGENTS.md could override them.
Plugins
N/A (source code analysis)
OpenCode version
main
Steps to reproduce
Read source code at packages/opencode/src/tool/write.txt and packages/opencode/src/tool/edit.txt
Note the false enforcement claims
Read write.ts and edit.ts — no runtime check exists
Also note writeWithDirs in fs-util.ts creates parent dirs silently
The core finding here (misleading enforcement text in write.txt/edit.txt) appears to be already documented in #30376. You may want to add any new details there rather than tracking separately.
Activity
github-actions commentedon Jun 4, 2026
This issue might be a duplicate of existing issues. Please check:
edit.txtandwrite.txt(Bug 1 and Bug 2), plus thewriteWithDirssilent directory creation concernThe core finding here (misleading enforcement text in
write.txt/edit.txt) appears to be already documented in #30376. You may want to add any new details there rather than tracking separately.