跳转到内容

LLMLLM 任务

llm-taskLLM 是一个可选插件工具,它运行仅限 JSON 的 LLM 任务并 返回结构化输出(可选择根据 JSON Schema 进行验证)。

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

  1. 启用插件:
{
"plugins": {
"entries": {
"llm-task": { "enabled": true }
}
}
}
  1. 允许使用可选工具:
{
"tools": {
"alsoAllow": ["llm-task"]
}
}

仅当您需要限制性白名单模式时,才使用 tools.allow

{
"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(数字,可选)

thinkingOpenClaw 接受标准的 OpenClaw 推理预设,例如 lowmedium

返回 details.json,其中包含已解析的 JSON(并在提供时根据 schema 进行验证)。

以下示例假设独立的 Lobster CLI在一个环境中运行,其中 LobsterCLIopenclaw.invoke 已具有正确的网关 URL/身份验证上下文。

对于 OpenClaw 内部捆绑的嵌入式 Lobster 运行器,此嵌套 CLI 模式目前不可靠

openclaw.invoke --tool llm-task --action json --args-json '{ ... }'

在嵌入式 Lobster 支持此流程的桥接之前,请选择以下任一方式:

  • 直接在 Lobster 外部调用 llm-taskLobster 工具,或者
  • 不依赖嵌套 Lobsteropenclaw.invoke 调用的 Lobster 步骤。

独立的 Lobster CLI 示例:

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)之前放置审批环节。