opencode icon indicating copy to clipboard operation
opencode copied to clipboard

[FEATURE]: Ability to override tool prompts - create model toolsets

Open conradkoh opened this issue 4 weeks ago • 1 comments

Feature hasn't been suggested before.

  • [x] I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

I want to have the ability to configure the tool prompts and override them. The problem I am trying to solve is that the prompt for the tool skews the AI model's usage of other tools.

For example, I have a tool raggrep that does semantic search. But because of the way that the grep tool or bash tool are defined (e.g. to push the AI to use the grep tool over running grep via bash), the raggrep tool rarely gets executed.


Possible solutions

Solution 1: Model type as first-class citizen

Ideally, we recognize that the effectiveness of tools can be greatly dependent on the model that is using the tools. Instead of just patching over it, the whole initial system prompt + environment + tool prompts should be a first-class citizen. When the model changes, all of these should be able to change.

//opencode.jsonc
{
    "build": {
      "mode": "primary",
      "prompt": "{file:./prompts/build.md}", //existing functionality on system prompt override
      "tools": {
        "bash": {
          "description": "custom description"
        }
      }
    }
}

Solution 2: Dynamic prompts

To support dynamic switching of toolsets in a declarative configuration might be challenging to maintain. An alternative is to add hooks that may alter a prompt, or completely override it - this would provide flexibility without the maintenance burden.

Example:

import type { PromptHooks } from '@opencode-ai/prompt';
import { tool } from '@opencode-ai/plugin';
// hook/prompt.ts
const hooks: PromptHooks = (e, oc) => {
    if(e.next.model.includes('claude')) {
        oc.tool.updatePrompt({
            "description": "custom tool description",
            "args": {
                "arg1": tool.schema.string().describe("custom arg description")
            }
        });
    }
}

export default hooks;

conradkoh avatar Dec 18 '25 06:12 conradkoh

that ability makes sense to have, would say tho if u have any suggestions for how we can tweak tools for different models we would prolly be happy to bake that in first party

rekram1-node avatar Dec 18 '25 22:12 rekram1-node