LLM Task

llm-task 是一个可选的 Plugin 工具,用于运行纯 JSON 的 LLM 任务,并返回结构化输出(可选择使用 JSON Schema 进行验证)。

这对于像 Lobster 这样的工作流引擎来说非常理想:你可以添加单个 LLM 步骤,而无需为每个工作流编写自定义的 OpenClaw 代码。

启用 Plugin

  1. 启用 Plugin:
{
  "plugins": {
    "entries": {
      "llm-task": { "enabled": true }
    }
  }
}
  1. 将工具加入白名单(它注册时带有 optional: true):
{
  "agents": {
    "list": [
      {
        "id": "main",
        "tools": { "allow": ["llm-task"] }
      }
    ]
  }
}

配置(可选)

{
  "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
        }
      }
    }
  }
}

allowedModelsprovider/model 字符串的白名单。如果设置了,任何不在列表中的请求都会被拒绝。

工具参数

  • prompt(字符串,必填)
  • input(任意类型,可选)
  • schema(对象,可选的 JSON Schema)
  • provider(字符串,可选)
  • model(字符串,可选)
  • authProfileId(字符串,可选)
  • temperature(数字,可选)
  • maxTokens(数字,可选)
  • timeoutMs(数字,可选)

输出

返回 details.json,包含解析后的 JSON(如果提供了 schema,会进行验证)。

示例: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
  }
}'

安全提示

  • 这个工具是纯 JSON 的,会指示模型只输出 JSON(没有代码围栏,没有注释)。
  • 这次运行不会向模型暴露任何工具。
  • 除非你用 schema 验证,否则要把输出当作不可信的。
  • 在任何有副作用的步骤(发送、发布、执行)之前加上审批。