Skip to content
广告 · 本站推荐广告

LLM Task

llm-task 是一个可选的插件工具,用于运行 JSON-only LLM 任务并返回结构化输出(可选地基于 JSON Schema 验证)。这非常适合 Lobster 等工作流引擎:你可以添加单个 LLM 步骤,而无需为每个工作流编写自定义 OpenClaw 代码。

启用插件

  1. 启用插件:
json
{
  "plugins": {
    "entries": {
      "llm-task": {
        "enabled": true
      }
    }
  }
}
  1. 将工具加入允许列表(它注册时带有 optional: true):
json
{
  "agents": {
    "list": [
      {
        "id": "main",
        "tools": {
          "allow": ["llm-task"]
        }
      }
    ]
  }
}

配置(可选)

json
{
  "plugins": {
    "entries": {
      "llm-task": {
        "enabled": true,
        "config": {
          "defaultProvider": "openai-codex",
          "defaultModel": "gpt-5.2",
          "defaultAuthProfileId": "main",
          "allowedModels": ["openai-codex/gpt-5.3-codex"],
          "maxTokens": 800,
          "timeoutMs": 30000
        }
      }
    }
  }
}

allowedModelsprovider/model 字符串的允许列表。如果已设置,不在列表中的任何请求都会被拒绝。

工具参数

  • prompt(string,必需)
  • input(any,可选)
  • schema(object,可选 JSON Schema)
  • provider(string,可选)
  • model(string,可选)
  • authProfileId(string,可选)
  • temperature(number,可选)
  • maxTokens(number,可选)
  • timeoutMs(number,可选)

输出

返回 details.json,包含解析后的 JSON(在提供 schema 时进行验证)。

示例:Lobster 工作流步骤

txt
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
  }
}'

安全注意事项

  • 该工具是 JSON-only 的,指示模型仅输出 JSON(无代码围栏、无注释)。
  • 此次运行中不会向模型暴露任何工具。
  • 除非你使用 schema 验证,否则应将输出视为不可信。
  • 在任何产生副作用的步骤(发送、发布、执行)之前添加审批环节。

基于MIT协议开源 | 内容翻译自 官方文档,同步更新