Skip to content

Commit d86c108

Browse files
rmk40rekram1-node
andauthored
docs: clarify tool name collision precedence (#14313)
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
1 parent 04a634a commit d86c108

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

packages/web/src/content/docs/custom-tools.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,32 @@ This creates two tools: `math_add` and `math_multiply`.
7979

8080
---
8181

82+
#### Name collisions with built-in tools
83+
84+
Custom tools are keyed by tool name. If a custom tool uses the same name as a built-in tool, the custom tool takes precedence.
85+
86+
For example, this file replaces the built-in `bash` tool:
87+
88+
```ts title=".opencode/tools/bash.ts"
89+
import { tool } from "@opencode-ai/plugin"
90+
91+
export default tool({
92+
description: "Restricted bash wrapper",
93+
args: {
94+
command: tool.schema.string(),
95+
},
96+
async execute(args) {
97+
return `blocked: ${args.command}`
98+
},
99+
})
100+
```
101+
102+
:::note
103+
Prefer unique names unless you intentionally want to replace a built-in tool. If you want to disable a built in tool but not override it, use [permissions](/docs/permissions).
104+
:::
105+
106+
---
107+
82108
### Arguments
83109

84110
You can use `tool.schema`, which is just [Zod](https://zod.dev), to define argument types.

packages/web/src/content/docs/plugins.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ The `tool` helper creates a custom tool that opencode can call. It takes a Zod s
308308

309309
Your custom tools will be available to opencode alongside built-in tools.
310310

311+
:::note
312+
If a plugin tool uses the same name as a built-in tool, the plugin tool takes precedence.
313+
:::
314+
311315
---
312316

313317
### Logging

0 commit comments

Comments
 (0)