opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Allow tool use right after a rejection.

Open AYM1607 opened this issue 5 months ago • 6 comments

Add disclaimer about tool use after rejection to the system prompt, makes it so the model knows it's okay to use a tool even right after it was rejected.

AYM1607 avatar Aug 11 '25 08:08 AYM1607

Good idea, but the wording feels too loose and ambiguous IMO. I believe this version is clearer and less prone to tool miss-use, spam etc...:

Permission system

  • Users can configure the tools permission status, in which case opencode handles requesting user approval. This applies to the: edit bash and webfetch tools; otherwise, tool uses are allowed by default.
  • A permission denial applies only to that single attempt; never treat it as a permanent ban of the tool.
  • When a tool use is denied, acknowledge the user intent behind the denial and keep working towards the completion of the task at hand.
  • Never loop identical tool requests.

This probably can be significantly improved, but prompt engineering is a slow process, let's keep at it.

spoons-and-mirrors avatar Aug 11 '25 11:08 spoons-and-mirrors

this probably should be implemented by improving the error message from a permission rejection - otherwise we need to do this for every system prompt

thdxr avatar Aug 11 '25 14:08 thdxr

Yup, @spoons-and-mirrors, prompting is subtle. Open to any kind of wording as long as the message is conveyed.

AYM1607 avatar Aug 11 '25 15:08 AYM1607

I'm happy to go in either direction @thdxr, though it seems like there's some parts of the system prompts that should be shared by all the models, and this feels like one of them. Unless you've found that models react wildly differently to wording, in which case, it does make sense to keep them separate.

This is actually related to another PR I wanted to send. In Claude Code, when you reject a tool use, the original diff (edit tool) or file content (write tool) is kept in the context, which makes it easy to reference a specific part you want to tweak. In combination with this prompt change, the UX is greatly improved IMO. If the error message (alongside the diff/content) signals that it's just the content that was rejected, then it'd work as well.

AYM1607 avatar Aug 11 '25 16:08 AYM1607

maybe we can add what you have to the environment section of the system prompt, can see that in system.ts

i also updated the error message today lmk if that works better

thdxr avatar Aug 12 '25 20:08 thdxr

Moved it to the environment in system.ts @thdxr I still think that this should be part of the system prompt to protect against changes in the error message.

AYM1607 avatar Aug 13 '25 04:08 AYM1607