Skip to content

Agent send

openclaw agent 從命令列執行單一 agent 輪次,無需傳入的聊天訊息。將其用於腳本化工作流程、測試和程式化傳遞。

  1. 執行簡單的 agent 週期

    Terminal window
    openclaw agent --message "What is the weather today?"

    這會透過 Gateway 發送訊息並列印回覆。

  2. 指定特定 agent 或 session

    Terminal window
    # Target a specific agent
    openclaw agent --agent ops --message "Summarize logs"
    # Target a phone number (derives session key)
    openclaw agent --to +15555550123 --message "Status update"
    # Reuse an existing session
    openclaw agent --session-id abc123 --message "Continue the task"
  3. 將回覆遞送到頻道

    Terminal window
    # Deliver to WhatsApp (default channel)
    openclaw agent --to +15555550123 --message "Report ready" --deliver
    # Deliver to Slack
    openclaw agent --agent ops --message "Generate report" \
    --deliver --reply-channel slack --reply-to "#reports"
標誌描述
--message \<text\>要發送的訊息(必填)
--to \<dest\>從目標(電話、聊天 ID)推導 session 金鑰
--agent \<id\>目標指定已配置的 agent (使用其 main session)
--session-id \<id\>依 ID 重複使用現有的 session
--local強制使用本機內嵌執行階段(跳過 Gateway)
--deliver將回覆發送到聊天頻道
--channel \<name\>遞送頻道(whatsapp、telegram、discord、slack 等)
--reply-to \<target\>遞送目標覆寫
--reply-channel \<name\>遞送頻道覆寫
--reply-account \<id\>遞送帳戶 ID 覆寫
--thinking \<level\>設定所選模型設定檔的思考層級
--verbose \<on|full|off\>設定詳細層級
--timeout \<seconds\>覆寫 agent 逾時
--json輸出結構化 JSON
  • 預設情況下,CLI 會 透過 Gateway 執行。新增 --local 以強制使用 當前機器上的嵌入式執行環境。
  • 如果 Gateway 無法連線,CLI 將回退到本機內嵌執行。
  • Session 選擇:--to 導出 session 金鑰 (群組/頻道目標 會保持隔離;直接聊天則合併為 main)。
  • 思考和詳細標誌會持續存在於 session store 中。
  • 輸出:預設為純文字,或是使用 --json 取得結構化 payload + 中繼資料。
  • 使用 --json --deliver 時,JSON 包含已發送、已隱藏、部分發送和發送失敗的傳送狀態。請參閱 JSON 傳送狀態
Terminal window
# Simple turn with JSON output
openclaw agent --to +15555550123 --message "Trace logs" --verbose on --json
# Turn with thinking level
openclaw agent --session-id 1234 --message "Summarize inbox" --thinking medium
# Deliver to a different channel than the session
openclaw agent --agent ops --message "Alert" --deliver --reply-channel telegram --reply-to "@admin"
Agent CLI 參考資料

完整的 openclaw agent 標誌和選項參考資料。

子代理程式

背景子代理程式產生。

Sessions

Session 金鑰的運作方式,以及 --to--agent--session-id 如何解析它們。

斜線指令

在代理程式 sessions 中使用的原生指令目錄。