Skip to content

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

@conradkoh

Description

@conradkoh

Feature hasn't been suggested before.

  • 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;

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions