You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/web/src/content/docs/custom-tools.mdx
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,6 +79,32 @@ This creates two tools: `math_add` and `math_multiply`.
79
79
80
80
---
81
81
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
+
exportdefaulttool({
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
+
82
108
### Arguments
83
109
84
110
You can use `tool.schema`, which is just [Zod](https://zod.dev), to define argument types.
0 commit comments