跳轉到主要內容

Documentation Index

Fetch the complete documentation index at: https://docs.openclaw.ai/llms.txt

Use this file to discover all available pages before exploring further.

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.5",
          "defaultAuthProfileId": "main",
          "allowedModels": ["openai/gpt-5.4"],
          "maxTokens": 800,
          "timeoutMs": 30000
        }
      }
    }
  }
}
allowedModelsprovider/model 字串的允許清單。如果已設定,清單以外的任何請求都會被拒絕。

工具參數

  • prompt(字串,必填)
  • input(任何值,選用)
  • schema(物件,選用 JSON Schema)
  • provider(字串,選用)
  • model(字串,選用)
  • thinking(字串,選用)
  • authProfileId(字串,選用)
  • temperature(數字,選用)
  • maxTokens(數字,選用)
  • timeoutMs(數字,選用)
thinking 接受標準的 OpenClaw 推理預設值,例如 lowmedium

輸出

傳回包含已解析 JSON 的 details.json(並在提供 schema 時依其驗證)。

範例:Lobster 工作流程步驟

openclaw.invoke --tool llm-task --action json --args-json '{
  "prompt": "Given the input email, return intent and draft.",
  "thinking": "low",
  "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 驗證,否則應將輸出視為不可信。
  • 在任何有副作用的步驟(send、post、exec)之前放置核准流程。

相關內容