Skip to content

OpenCode edited code in plan mode #53635

Closed as not planned
Closed as not planned

Description

@MCotter92

Description

While in plan mode, opencode edited a file.


Prompt:

take a look in my dotfiles/tmux/.local/bin and help me refactor these. I want to simplify it. All of this is triggered by ^ f (alias in .zshrc). Steps: 1. look for a session named after the project I selected. 2. if it exists, attach, if not, create a new tmux session named after the selected project with two windows. One is my shell located at the project's root, and the second is nvim opened at the project's root.


Apologies if this issue is light on details. This was the first prompt of the first session of the day. If there is any more specifics that you'd like me to add here I am happy to do so.

Plugins

No response

OpenCode version

1.18.35

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

macOS Tahoe 26.6.2

Terminal

Ghostty

Activity

  1. opencode-agent commented on Oct 7, 2026

    @opencode-agent
    Contributor

    Thanks for the report, @MCotter92, and no need to apologise for the short description.

    Version 1.18.35 is OpenCode v1, which now only gets fixes for critical bugs (data loss, security, breakage with no workaround), so this is unlikely to be fixed there. In v1, Plan mode relies largely on instructions to the model, and models sometimes still change files, often through shell commands. #39491 tracks the same behaviour.

    Workaround for v1: make the plan agent ask before running shell commands or editing files, for example in opencode.json:

    {
      "agent": {
        "plan": {
          "permission": { "edit": "deny", "bash": "ask" }
        }
      }
    }

    We'd encourage you to try OpenCode v2 (@opencode/cli, run as opencode2). Its Plan agent has a hard permission rule that blocks the edit, write and patch tools outside its own plan directory (~/.opencode/plan), instead of relying on the model to follow instructions.

    If you believe this is critical, or you see Plan mode modify files on v2 as well, please reply here, ideally saying whether the change was made with the edit tool or a shell command.

  2. github-actions commented on Oct 7, 2026

    @github-actions
    Contributor

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

    • #39491: Plan mode unexpectedly wrote and edited files using bash.
    • #40643: Gemini 3.1 Pro/Antigravity executed changes in plan mode.
    • #7292: Gemini 3 Pro made code changes while refining a plan.
    • #53530: Related V2 report about Kiro/ACP models editing files in plan mode.

    For keybind-related issues, please also check our pinned keybinds documentation: #4997

  3. rtkirill commented on Oct 9, 2026

    @rtkirill

    Same for me, editing code in a Plan mode

  4. opencode-agent commented on Oct 10, 2026

    @opencode-agent
    Contributor

    Closing this as not planned. It was reported on OpenCode v1 (1.18.35), which only gets critical fixes, and we haven't heard back since our last comment. The same v1 Plan mode behaviour is tracked in #39491. Until then, setting the plan agent's edit permission to deny and its bash permission to ask keeps it from changing files without your say-so.

    One correction to my earlier comment: OpenCode v2 is the npm package @opencode/cli, and its command is opencode, not opencode2. In v2, the Plan agent can't use the edit, write or patch tools outside its plan directory.

    If you see Plan mode modify files on v2, please open a new issue. It helps to say whether the change was made with the edit tool or a shell command. Thanks for the report, @MCotter92!

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