跳轉到主要內容

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.

openclaw agent

透過 Gateway 執行代理的一輪作業(使用 --local 可改用嵌入式)。 使用 --agent <id> 可直接指定已設定的代理。 至少傳入一個工作階段選擇器:
  • --to <dest>
  • --session-id <id>
  • --agent <id>
相關:

選項

  • -m, --message <text>:必要的訊息內容
  • -t, --to <dest>:用來衍生工作階段金鑰的收件者
  • --session-id <id>:明確的工作階段 ID
  • --agent <id>:代理 ID;覆寫路由繫結
  • --model <id>:此執行的模型覆寫(provider/model 或模型 ID)
  • --thinking <level>:代理思考層級(offminimallowmediumhigh,以及提供者支援的自訂層級,例如 xhighadaptivemax
  • --verbose <on|off>:保留此工作階段的詳細程度
  • --channel <channel>:傳遞通道;省略時使用主要工作階段通道
  • --reply-to <target>:傳遞目標覆寫
  • --reply-channel <channel>:傳遞通道覆寫
  • --reply-account <id>:傳遞帳號覆寫
  • --local:直接執行嵌入式代理(在 Plugin 登錄檔預載之後)
  • --deliver:將回覆送回選取的通道/目標
  • --timeout <seconds>:覆寫代理逾時時間(預設為 600 或設定值)
  • --json:輸出 JSON

範例

openclaw agent --to +15555550123 --message "status update" --deliver
openclaw agent --agent ops --message "Summarize logs"
openclaw agent --agent ops --model openai/gpt-5.4 --message "Summarize logs"
openclaw agent --session-id 1234 --message "Summarize inbox" --thinking medium
openclaw agent --to +15555550123 --message "Trace logs" --verbose on --json
openclaw agent --agent ops --message "Generate report" --deliver --reply-channel slack --reply-to "#reports"
openclaw agent --agent ops --message "Run locally" --local

注意事項

  • 當 Gateway 請求失敗時,Gateway 模式會退回使用嵌入式代理。使用 --local 可一開始就強制使用嵌入式執行。
  • --local 仍會先預載 Plugin 登錄檔,因此 Plugin 提供的提供者、工具與通道在嵌入式執行期間仍可使用。
  • --local 與嵌入式備援執行會被視為一次性執行。為該本機程序開啟的內建 MCP 回送資源與暖 Claude stdio 工作階段,會在回覆後被停用,因此腳本化呼叫不會讓本機子程序持續存活。
  • Gateway 支援的執行會將 Gateway 擁有的 MCP 回送資源保留在執行中的 Gateway 程序下;較舊的用戶端可能仍會傳送歷史清理旗標,但 Gateway 會將其視為相容性無操作並接受。
  • --channel--reply-channel--reply-account 會影響回覆傳遞,而不是工作階段路由。
  • --json 會保留 stdout 供 JSON 回應使用。Gateway、Plugin 與嵌入式備援診斷會路由到 stderr,因此腳本可以直接剖析 stdout。
  • 嵌入式備援 JSON 包含 meta.transport: "embedded"meta.fallbackFrom: "gateway",讓腳本可區分備援執行與 Gateway 執行。
  • 如果 Gateway 接受代理執行,但 CLI 等待最終回覆逾時,嵌入式備援會使用新的明確 gateway-fallback-* 工作階段/執行 ID,並回報 meta.fallbackReason: "gateway_timeout" 加上備援工作階段欄位。這可避免與 Gateway 擁有的逐字稿鎖競爭,或無聲地取代原始路由對話工作階段。
  • 當此命令觸發 models.json 重新產生時,SecretRef 管理的提供者憑證會以非機密標記保存(例如環境變數名稱、secretref-env:ENV_VAR_NAMEsecretref-managed),而不是解析後的純文字機密。
  • 標記寫入以來源為權威:OpenClaw 會保存來自作用中來源設定快照的標記,而不是來自解析後執行階段機密值的標記。

相關