Files
openclaw/docs/plugins/agent-tools.md

100 lines
2.6 KiB
Markdown
Raw Permalink Normal View History

2026-01-18 04:07:19 +00:00
---
summary: "Write agent tools in a plugin (schemas, optional tools, allowlists)"
read_when:
- You want to add a new agent tool in a plugin
- You need to make a tool opt-in via allowlists
title: "Plugin Agent Tools"
2026-01-18 04:07:19 +00:00
---
2026-01-31 21:13:13 +09:00
2026-01-18 04:07:19 +00:00
# Plugin agent tools
2026-01-30 03:15:10 +01:00
OpenClaw plugins can register **agent tools** (JSONschema functions) that are exposed
2026-01-18 04:27:50 +00:00
to the LLM during agent runs. Tools can be **required** (always available) or
**optional** (optin).
Agent tools are configured under `tools` in the main config, or peragent under
`agents.list[].tools`. The allowlist/denylist policy controls which tools the agent
can call.
2026-01-18 04:07:19 +00:00
## Basic tool
```ts
import { Type } from "@sinclair/typebox";
export default function (api) {
api.registerTool({
name: "my_tool",
description: "Do a thing",
parameters: Type.Object({
input: Type.String(),
}),
async execute(_id, params) {
return { content: [{ type: "text", text: params.input }] };
},
});
}
```
## Optional tool (optin)
Optional tools are **never** autoenabled. Users must add them to an agent
allowlist.
```ts
export default function (api) {
api.registerTool(
{
name: "workflow_tool",
description: "Run a local workflow",
parameters: {
type: "object",
properties: {
pipeline: { type: "string" },
},
required: ["pipeline"],
},
async execute(_id, params) {
return { content: [{ type: "text", text: params.pipeline }] };
},
},
{ optional: true },
);
}
```
2026-01-18 04:27:50 +00:00
Enable optional tools in `agents.list[].tools.allow` (or global `tools.allow`):
2026-01-18 04:07:19 +00:00
```json5
{
agents: {
list: [
{
id: "main",
tools: {
allow: [
2026-01-31 21:13:13 +09:00
"workflow_tool", // specific tool name
"workflow", // plugin id (enables all tools from that plugin)
"group:plugins", // all plugin tools
],
},
},
],
},
2026-01-18 04:07:19 +00:00
}
```
2026-01-18 04:27:50 +00:00
Other config knobs that affect tool availability:
2026-01-31 21:13:13 +09:00
- Allowlists that only name plugin tools are treated as plugin opt-ins; core tools remain
enabled unless you also include core tools or groups in the allowlist.
2026-01-18 04:27:50 +00:00
- `tools.profile` / `agents.list[].tools.profile` (base allowlist)
- `tools.byProvider` / `agents.list[].tools.byProvider` (providerspecific allow/deny)
- `tools.sandbox.tools.*` (sandbox tool policy when sandboxed)
2026-01-18 04:07:19 +00:00
## Rules + tips
- Tool names must **not** clash with core tool names; conflicting tools are skipped.
- Plugin ids used in allowlists must not clash with core tool names.
- Prefer `optional: true` for tools that trigger side effects or require extra
binaries/credentials.