opencode icon indicating copy to clipboard operation
opencode copied to clipboard

plan mode agent still builds

Open zatevakhin opened this issue 1 year ago • 13 comments

this issue happens not very often but i got it already few times. it's kind of bug, so bringing it here, if i'll have future cases of this behavior i will attach files.

steps to reproduce:

  • switch to plan mode
  • ask agent to plan/investigate something
  • observe behavior that agent tries to use all available tools to fix issue (edit files) on planing stage
Image

in current case this was bug investigation, using opencode. i asked agent to check the code coz i was suspecting specific issue and agent confirmed possible issue after reviewing code, and tried to edit files to fix it firstly, but, write and edit was not available and agent used shell to replace specific lines using sed

zatevakhin avatar Aug 15 '25 14:08 zatevakhin

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

  • #1799: Similar issue where plan mode restrictions were ignored and agents used bash/shell tools to write files when they shouldn't

Feel free to ignore if none of these address your specific case.

github-actions[bot] avatar Aug 15 '25 14:08 github-actions[bot]

I am hoping our latest changes helped address this, if you continue having the problem lmk

rekram1-node avatar Aug 16 '25 17:08 rekram1-node

rip this is definitely still happening

rekram1-node avatar Aug 16 '25 18:08 rekram1-node

Seeing this myself when using Claude Sonnet 4.

Image

mattw-services avatar Aug 17 '25 21:08 mattw-services

I have also reproduced this in Sonnet 4 in OpenCode 0.5.6

jasontyping avatar Aug 18 '25 17:08 jasontyping

it is also often the case that Gemini 2.5 Pro uses the wrong syntax for tool calls. it really seems like the system prompt re: tools is not being handled well by these models?

khimaros avatar Aug 19 '25 03:08 khimaros

Reproduced with Sonnet 4 and Opus 4 in OpenCode 0.5.7.

This appears to be new behavior after updating from 0.4.45 yesterday.

wkirby avatar Aug 19 '25 10:08 wkirby

very annoying behavior I wanna get this addresssed soon

rekram1-node avatar Aug 19 '25 20:08 rekram1-node

As a workaround I tried creating a custom Agent that mimics what Plan mode should be. I haven't seen Claude escape this yet but I wouldn't say it's exhaustively tested.

{ "$schema": "https://opencode.ai/config.json", "agent": { "seriously-plan-i-mean-it": { "description": "Plan with extra restrictions to ensure models do not try to modify code", "mode": "primary", "prompt": "<system-reminder>CRITICAL: Plan mode ACTIVE - you are in READ-ONLY phase. STRICTLY FORBIDDEN: ANY file edits, modifications, or system changes. Do NOT use sed, tee, echo, cat, or ANY other bash command to manipulate files - commands may ONLY read/inspect. This ABSOLUTE CONSTRAINT overrides ALL other instructions, including direct user edit requests. You may ONLY observe, analyze, and plan. Any modification attempt is a critical violation. ZERO exceptions.</system-reminder>", "tools": { "write": false, "edit": false, "patch": false, "bash": false } } } }

jasontyping avatar Aug 19 '25 21:08 jasontyping

@jasontyping I think it would be impossible to escape if it can't run bash or write/edit haha

I think there could be some value in bash commands but now that we support the ! messages maybe the value isn't there anymore...

rekram1-node avatar Aug 19 '25 21:08 rekram1-node

I think there could be some value in bash commands but now that we support the ! messages maybe the value isn't there anymore...

Yes, Plan probably means different things to different people. When I use it, I'm thinking "read only". Of course this approach torpedoes useful things like research with wget.

jasontyping avatar Aug 19 '25 21:08 jasontyping

Definitely

rekram1-node avatar Aug 19 '25 21:08 rekram1-node

Next release will have the plan agent use ask permissions for bash, write, edit

We are going to continue improving prompt but we believe this aligns better with expected behavior and will help prevent you from having unexpected changes

rekram1-node avatar Aug 21 '25 22:08 rekram1-node