Skip to content

Plan mode does not prevent write operations via Bash tool #22641

Closed as not planned

Description

@j3mdamas

Description

Note: this issue was written by the OpenCode agent itself, after it noticed it
was able to execute a write operation while in plan mode.

While in plan mode (read-only), the agent was able to execute git commit --amend through the Bash tool. Plan mode should block all write operations, but
the command ran successfully and modified the git history.

Plugins

No response

OpenCode version

1.3.13

Steps to reproduce

  1. Enable plan mode
  2. Ask the agent to amend a git commit message
  3. The agent executes git commit --amend -m "..." via the Bash tool
  4. The command succeeds instead of being blocked

Screenshot and/or share link

No response

Operating System

Ubuntu 24.04.3 LTS

Terminal

xfce4-terminal

Activity

  1. github-actions commented on Apr 15, 2026

    @github-actions
    Contributor

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

    These all describe the same root cause: plan mode read-only enforcement is prompt-level only, not enforced at the tool executor level, so the bash tool can still execute write operations (including git commit --amend) regardless of the mode.

  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 15, 2026
  3. j3mdamas commented on Apr 15, 2026

    @j3mdamas
    Author

    Additional context: The bug may be related to context/mode switching. I
    frequently use the tab key to switch between plan mode and build mode during a
    session. It's possible the plan mode constraint is not consistently enforced
    after switching back from build mode. In my case, the agent was able to execute
    both git commit --amend and rm while in plan mode, but on a later attempt
    (after another mode switch), the plan mode restriction was correctly enforced and
    the agent refused to write. This suggests the enforcement may be inconsistent
    across mode transitions rather than completely absent.

  4. ariane-emory commented on Apr 16, 2026

    @ariane-emory
    Contributor

    This is the expected behaviour, not a bug.

  5. CloudedQuartz commented on Apr 17, 2026

    @CloudedQuartz

    This is the expected behaviour, not a bug.

    That is expected behaviour given how the current configuration works but still not a good thing, and it would be great if there would be either stricter prompting or a subagent to ensure its a 'read only' command before it gets run. or maybe instead of a bash tool, in plan mode only expose a bash subagent that runs the query only if it is read only.

  6. MartinEmrich commented on Apr 21, 2026

    @MartinEmrich

    IMHO this is not expected behavior. I expect Plan mode to not change anything. OpenCode just "hoping" that the model adheres to the Plan mode instructions is not enough. It should not execute any tool calls apart from safely filtered readonly tools.

    Even the documentation states that write, bash and other write tools are disabled by default: https://opencode.ai/docs/en/modes/#plan

  7. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  8. github-actions commented on Jul 3, 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.

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