r/opencode • • 25d ago

So we not safe in plan mode?

Post image
94 Upvotes

32 comments sorted by

6

u/0xbyt3 25d ago

Which model? It can run command that isn't in its "disallow" list too. I am seeing opencode running "git commit" without an issue.

4

u/BrownCarter 25d ago

It's deepseek v4.1

3

u/xatey93152 25d ago

Lol of course.

8

u/Asonagic 25d ago

DOES YOUR AGENT DEPLOY THINGS???

4

u/BrownCarter 25d ago

Yeah it does 🥲

8

u/Takeoded 25d ago

Wait, yours don't?

2

u/EvilGuy 25d ago

This has been a bug for a long time now.. at least 6 months ago I opened a bug on the github about it doing this. Was it the main agent or was it a sub agent?

1

u/BrownCarter 25d ago

Main agent

1

u/EvilGuy 25d ago

Hmm that's new maybe the main agent used to be pretty safe but the sub agents would do whatever they wanted.

56

u/Vlyn 25d ago

OpenCode Plan Mode is just a prompt in the end, not a guarantee.

You have two options:

  1. Fully sandbox your agent where no matter what it does it can't do much damage.
  2. Use something like pi with pi-automode, where you have a second model (or the same model) double check every single tool call. So bad calls instantly get blocked and something that doesn't align with what you wanted (you said just write a plan, the main agent tries to edit files) usually gets blocked too. But it's just a layer of protection, no guarantee at all.

4

u/tsangberg 25d ago

This.

I created my own sandboxing system for this. Feel free to reuse whatever might suit somebody else.

Without a proper sandbox you _will_ lose important data at some point.

https://verified.technology/

0

u/[deleted] 24d ago

[deleted] — view deleted comment

2

u/tsangberg 24d ago

Because the one I made (see the link) has much more functionality that suits the workflow I use LLMs for. Esp. the ability for an LLM on one host to remote into another host - still sandboxed - makes trusting agents with typical sysadm tasks a lot easier. Another would be the sudoers-like ability to run tasks direcly on the host without opening up for anything but that very specific task.

1

u/Fruloops 21d ago

Why not?

2

u/james__jam 25d ago

You can specify what tools a primary agent has right?

2

u/Vlyn 25d ago

Kinda. If you hard deny bash and all other shell access and only give it the read tool? Then it would be mostly safe.

As soon as you give it edit permissions then all bets are off (if the agent actually tries to do something malicious on your machine). For normal workflows blocking or always asking for bash would be pretty safe though.

Besides the whole point: An agent that can't use bash, Python scripts etc. won't be great at writing code.

Starting out with Claude Code and then OpenCode at work we always checked every single tool call (only giving "always" allowed to pure reads). But over time you read the calls less and less and just hit allow. So currently I like my setup more of a second model checking every call. Your main agent might start doing something stupid as it really wants to finish a task, the second model without the same context will block it.

1

u/JorgeMiralles 24d ago

You can run OpenCode inside a Docker Container as a sandbox.

7

u/Big_Day6767 25d ago

Have you updated your opencode json to change the permission settings in plan mode?
Because plan mode should have a guardrail that doesn’t allow file edits.

If you have allowed file edits then it’s basically just a prompt that says don’t edit which can obviously be violated. You might have also allowed file edits earlier in the conversation and made it apply to the entire conversation.

4

u/MrSchmellow 25d ago

It does have a guardrail for edit tool or whatever it's called, but does not have one for shell by default. So it can escape pretty easily. I've seen it myself when in response to a theoretical question it started making a test project in /tmp to verify a hypothesis lol

https://github.com/anomalyco/opencode/issues/60250 - one of the (many) related bug reports for example.

It also cuts both ways - plan agent prompt is something like "you can't write anywhere except .opencode/plans and unless asked". Well, some models refuse to write plans even when asked (i think it was claude)

1

u/NoLemurs 24d ago

Fundamentally, as long as you want to allow shell access, you can't use plan mode to prevent edits. Agents can, and often will use the shell to write files. Sometimes without even trying the file edit tools first. The permission settings might catch some or even most attempts at editing files, but it's at best a statistical game.

Meanwhile, cutting off shell access prevents a ton of stuff you absolutely want your plan mode agents to be able to do.

Sandboxing plus good git hygiene is the right solution to this problem, and once you have a good sandbox, it's much more convenient to just turn off all the permissions and let the agent do whatever it wants.

The permissions system in opencode is just not worth engaging with.

4

u/lilian_moraru 24d ago

Recommended: https://github.com/Dicklesworthstone/destructive_command_guard
You just tell the agent to set it up for OpenCode. At least some protection from dangerous commands - the agents get blocked and start using “git switch”(backups) instead of “git reset —hard” and more temporary directories when they try to do “rm -rf $somePotentiallyEmptyVar/” and get rejected.

2

u/CupZealous 25d ago

I use Hermes Agent with my OpenCode Go sub, the plan mode restricts tool calls

2

u/AveryFenix 21d ago

Mine keeps thinking its in plan mode and asking me to switch to build mode WHEN ITS IN BUILD MODE.

1

u/Mammoth_Ad_9619 25d ago

I haven't any issue with plan or build mode.

Nowadays I'm using omo slim plugin and it worked really great.

1

u/NEROisADRIO 25d ago

Sub agent can change things in open code

1

u/Roy197 24d ago

This has also happened to me in Claude code it's nothing new

1

u/ichisay 24d ago

Revisa los permisos en el json. Puedes de negarle el uso de herramientas y te aseguras de esa forma que no toque nada que no debe. Siempre se deben revisar los permisos y su prompt.

1

u/AlwaysHopelesslyLost 24d ago

Yep, welcome to the world of security. Turning complete makes anything possible, including bypassing any possible blacklist.

1

u/LeoVibeCoderz 20d ago

I has the same issue recently and asked the same questions.

0

u/Rude-Philosopher-69 25d ago

this is the main reason i created oc-box.

Run OpenCode, MCP servers, formatters, plugins, and development tools together inside a container, with native language servers on OpenCode 1.x. Give the agent control of that environment while exposing only your selected project directory by default.

enjoy!

https://github.com/groopcd/oc-box

-1

u/ZoldarAR 25d ago

What IDE / Coding App do you people use with OpenCode?

1

u/povlhp 25d ago

It says so clearly. Holes in the harness. Your fault