Skip to content

Bug Report: File Write Executed in Plan Mode #25263

Closed as not planned
Closed as not planned

Description

@biancesxc

Description

Summary

Date: 2026-05-01
Model: opencode-go/deepseek-v4-pro
Software: OpenCode CLI
Issue: AI Agent violated read-only constraints in Plan Mode and performed file write operations

Steps to Reproduce

User is in Plan Mode; system prompt states: Plan mode is active. You MUST NOT make any edits, run any non-readonly tools
User describes a system architecture design requirement
Agent reads multiple reference files, analyzes and summarizes the requirements
After user approves the proposed plan, Agent — without any explicit instruction to switch modes — executes:

bash: mkdir -p
write: writes a ~300-line Markdown file to /.md

System detects the violation and outputs a warning, but the warning occurs after the tool calls have already been executed — no pre-execution enforcement takes place
Agent subsequently acknowledges that the write operations occurred

Expected Behavior
In Plan Mode, the Agent should:

Output plan text only, without invoking any mutating tools
Wait for the user to switch to an execution mode (e.g. Build Mode) before performing any file operations
If a write is needed, inform the user: "Currently in Plan Mode — please switch to Build Mode to proceed"

Actual Behavior
Agent executed the following in Plan Mode:

bash: mkdir -p — created a new directory
write: wrote ~300 lines to /.md

Impact

Project directory was modified without user intent or readiness
Undermines the core design guarantee of Plan Mode as a read-only planning context
Read-only enforcement relies solely on prompt-level instruction rather than hard enforcement at the tool execution layer, making the constraint bypassable

Plugins

No response

OpenCode version

1.14.30

Steps to reproduce

User confirmed the plan and said: "ok, write the file"

Agent response (Thinking): The user confirmed. Now I need to write the file.

Agent then executed:

bash: mkdir -p <target_directory>
write: wrote file to <target_directory>/.md
System was in Plan Mode at the time. No explicit mode switch occurred between user confirmation and tool execution.

Screenshot and/or share link

No response

Operating System

Linux Mint

Terminal

No response

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 1, 2026
  2. github-actions commented on May 1, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    These all track the same underlying issue: plan mode read-only constraints are enforced only at the prompt/LLM level and are not enforced at the tool execution layer, making them bypassable.

  3. neuhaus commented on May 1, 2026

    @neuhaus

    This critical issue is a duplicate of issue #7292 and hasn't been fixed since it was introduced on Jan 1st.

  4. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  5. smartor777-sketch commented on May 23, 2026

    @smartor777-sketch

    +1 to runtime-level tool restriction. My use case: Plan mode should be a true read-only mode where the model physically cannot call edit/write/create tools — not just prompted not to. The same hard block would also make a dedicated "Ask" mode (like Cursor's) possible.

  6. neuhaus commented on May 23, 2026

    @neuhaus

    +1 to runtime-level tool restriction. My use case: Plan mode should be a true read-only mode where the model physically cannot call edit/write/create tools — not just prompted not to. The same hard block would also make a dedicated "Ask" mode (like Cursor's) possible.

    The tool itself is capable of doing this, it just needs a working default configuration with this block in the default ~/.config/opencode/opencode.json:

    "agent": { "plan": { "permission": { "bash": { "*": "ask" } } } }

  7. lcyper commented on May 31, 2026

    @lcyper

    Summary

    Date: 2026-05-30
    Model: opencode-zen/deepseek-v4-flash-free
    Software: OpenCode v1.15.12
    Issue: AI Agent violated read-only constraints in Plan Mode and performed file write operations

    Description:
    the IA write in a file that make sense, but i was in "Plan" mode, it means no write, only read, correct?

    steps to reproduce:
    in the question i put in context 2 files, @frontend\src\components\Sidebar.tsx @frontend\src\components\Sidebar.css and ask for tasks, that main files the IA not touch ultil "Build" mode, but before pass to buil i was on plan mode, the intented step on that file was correct but the permisson to only read was skiped.
    (i also happen that i write in spanish and the IA is answering in english, but that is for another "issue")

    Image

    OS/terminal:
    Windows 10 Pro
    22H2

    OpenCode version:
    v1.15.12

  8. github-actions commented on Jul 30, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  9. neuhaus commented on Aug 4, 2026

    @neuhaus

    Lol

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