Description
The Question tool can be used as a substitute for the Read tool because:
-
Question tool output is structurally identical -- question.ts returns answers as plain text. To the AI conversation history, a Question answer looks the same as Read output.
-
No runtime enforcement in edit tools -- edit.ts, write.ts, and bash.ts have zero checks verifying the file was read via the Read tool before editing. The tool descriptions claim read-before-edit is required, but there is no code backing this claim.
-
No session-level read tracking -- there is no mechanism to distinguish whether file content came from a Read call or a Question answer. The AI could ask "What is the content of src/main.ts?", receive the answer, then edit the file -- all without ever calling Read.
Reproduction steps
- Start an opencode session
- Ask the AI to modify a file it has not read yet
- When the AI calls question asking "What is the current content of ?", paste the file content as your answer
- The AI now has the content and can call edit/write with correct oldString -- the edit will succeed because there is no Read-tool check in the editing tools
Code paths
- question.ts returns plain text answers, structurally same as Read output
- edit.ts, write.ts -- zero read-before-edit enforcement
- bash.ts -- no enforcement either
Related
This is one instance of a broader pattern tracked in #30376 (missing code-level read-before-edit enforcement across all tools).
Description
The Question tool can be used as a substitute for the Read tool because:
Question tool output is structurally identical -- question.ts returns answers as plain text. To the AI conversation history, a Question answer looks the same as Read output.
No runtime enforcement in edit tools -- edit.ts, write.ts, and bash.ts have zero checks verifying the file was read via the Read tool before editing. The tool descriptions claim read-before-edit is required, but there is no code backing this claim.
No session-level read tracking -- there is no mechanism to distinguish whether file content came from a Read call or a Question answer. The AI could ask "What is the content of src/main.ts?", receive the answer, then edit the file -- all without ever calling Read.
Reproduction steps
Code paths
Related
This is one instance of a broader pattern tracked in #30376 (missing code-level read-before-edit enforcement across all tools).