工具 & 技能 • 5 分钟阅读
LLM Task
用于工作流的仅 JSON LLM 任务(可选插件工具)
''llm-task'' 是一个''可选插件工具'',运行仅 JSON 的 LLM 任务并
返回结构化输出(可选择根据 JSON Schema 验证)。
这对于 Lobster 等工作流引擎非常理想:您可以添加单个 LLM 步骤
而无需为每个工作流编写自定义 OpenClaw 代码。
Tutorial.step
启用插件
1. 启用插件:
Json
{
"plugins": {
"entries": {
"llm-task": { "enabled": true }
}
}
}2. 将工具加入允许列表(它以 ''optional: true'' 注册):
Json
{
"agents": {
"list": [
{
"id": "main",
"tools": { "allow": ["llm-task"] }
}
]
}
}Tutorial.step
配置(可选)
Json
{
"plugins": {
"entries": {
"llm-task": {
"enabled": true,
"config": {
"defaultProvider": "openai-codex",
"defaultModel": "gpt-5.2",
"defaultAuthProfileId": "main",
"allowedModels": ["openai-codex/gpt-5.2"],
"maxTokens": 800,
"timeoutMs": 30000
}
}
}
}
}''allowedModels'' 是 ''provider/model'' 字符串的允许列表。如果设置,任何
不在列表中的请求都会被拒绝。
Tutorial.step
工具参数
- ''prompt''(字符串,必需)
- ''input''(任意,可选)
- ''schema''(对象,可选 JSON Schema)
- ''provider''(字符串,可选)
- ''model''(字符串,可选)
- ''authProfileId''(字符串,可选)
- ''temperature''(数字,可选)
- ''maxTokens''(数字,可选)
- ''timeoutMs''(数字,可选)
Tutorial.step
输出
返回包含解析后 JSON 的 ''details.json''(并在提供时根据
''schema'' 验证)。
Tutorial.step
示例:Lobster 工作流步骤
Lobster
openclaw.invoke --tool llm-task --action json --args-json '{
"prompt": "Given the input email, return intent and draft.",
"input": {
"subject": "Hello",
"body": "Can you help?"
},
"schema": {
"type": "object",
"properties": {
"intent": { "type": "string" },
"draft": { "type": "string" }
},
"required": ["intent", "draft"],
"additionalProperties": false
}
}'Tutorial.step
安全注意事项
- 该工具是仅 JSON 的,并指示模型仅输出 JSON(无
代码围栏,无注释)。
- 此运行不会向模型暴露任何工具。
- 除非使用 ''schema'' 验证,否则将输出视为不可信。
- 在任何副作用步骤(发送、发布、执行)之前放置审批。