Skip to content

[BUG]: Plan-to-build transition does not tell AI to re-read files before editing -- stale plan-mode knowledge used #30784

Closed

Description

Description

When the AI transitions from plan mode to build mode, the build-switch.txt message (packages/opencode/src/session/prompt/build-switch.txt) tells the AI:

You are no longer in read-only mode.
You are permitted to make file changes, run shell commands, and utilize your arsenal of tools as needed.

It does not tell the AI to re-read files before editing them.

The problem

During plan mode, the AI may have read files many turns ago. File content could have changed. The AI's knowledge of file contents may be stale. But the build switch message gives no instruction to re-verify.

Compare with the plan mode prompt (plan-reminder-anthropic.txt:48) which DOES tell the AI:

"Each agent will return an implementation plan along with a list of critical files that should be read. You should keep these in mind and read them before you start implementing the plan."

This instruction is present in plan mode but is not repeated at the transition to build mode.

Experimental mode also affected

The experimental plan mode prompt (plan-mode.txt) also doesn't include a re-read instruction at transition. reminders.ts lines 51-68 add only the plan file location.

Related: #30766 (prompts missing read-before-edit instruction), #30767 (no session tracking — plan-mode reads could be timestamped)

Plugins

N/A (source code analysis)

OpenCode version

main

Steps to reproduce

  1. Start plan mode, AI reads src/main.ts (turn 5)
  2. AI spends 30 turns planning
  3. User approves plan, AI transitions to build mode
  4. AI edits src/main.ts based on content recalled from turn 5
  5. If src/main.ts changed during this time, the edit may corrupt the file

Screenshot and/or share link

N/A (we read the source code)

Operating System

N/A (code analysis, not environment-specific)

Terminal

N/A

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