插件 agent 工具
OpenClaw 插件可以注册 agent 工具(JSON Schema 函数),在 agent 运行时暴露给 LLM。工具可以是必需的(始终可用)或可选的(需手动开启)。
Agent 工具在主配置的 tools 下配置,也可以在 agents.list[].tools 中按 agent 配置。白名单/黑名单策略控制 agent 可以调用哪些工具。
基本工具
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 }] };
},
});
}
可选工具(需手动开启)
可选工具永远不会被自动启用。用户必须将其添加到 agent 的白名单中。
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 },
);
}
在 agents.list[].tools.allow(或全局 tools.allow)中启用可选工具:
{
agents: {
list: [
{
id: "main",
tools: {
allow: [
"workflow_tool", // 具体工具名
"workflow", // 插件 ID(启用该插件的所有工具)
"group:plugins", // 所有插件工具
],
},
},
],
},
}
其他影响工具可用性的配置项:
- 仅包含插件工具名的白名单被视为插件的显式开启;核心工具仍然保持启用,除非你也在白名单中包含了核心工具或工具组。
tools.profile/agents.list[].tools.profile(基础白名单)tools.byProvider/agents.list[].tools.byProvider(按 provider 的允许/拒绝)tools.sandbox.tools.*(沙箱环境下的工具策略)
规则与建议
- 工具名不得与核心工具名冲突;冲突的工具会被跳过。
- 白名单中使用的插件 ID 不得与核心工具名冲突。
- 对于会触发副作用或需要额外二进制/凭据的工具,建议使用
optional: true。