Agent coordination
代理傳送
openclaw agent 可從命令列執行單次代理程式回合,不需要收到
傳入的聊天訊息。可用於指令碼工作流程、測試及
程式化傳送。完整旗標與行為參考:
代理程式命令列介面參考。
快速開始
執行簡單的代理程式回合
openclaw agent --agent main --message "今天天氣如何?"透過閘道傳送訊息並印出回覆。
從檔案傳送多行提示
openclaw agent --agent ops --message-file ./task.md讀取有效的 UTF-8 檔案,作為代理程式訊息本文。
指定特定代理程式或工作階段
# 指定特定代理程式openclaw agent --agent ops --message "摘要記錄" # 指定電話號碼(衍生工作階段金鑰)openclaw agent --to +15555550123 --message "狀態更新" # 重複使用現有工作階段openclaw agent --session-id abc123 --message "繼續執行工作" # 指定確切的工作階段金鑰openclaw agent --session-key agent:ops:incident-42 --message "摘要狀態"將回覆傳送至頻道
# 傳送至 WhatsApp(預設頻道)openclaw agent --to +15555550123 --message "報告已就緒" --deliver # 傳送至 Slackopenclaw agent --agent ops --message "產生報告" \ --deliver --reply-channel slack --reply-to "#reports"旗標
| 旗標 | 說明 |
|---|---|
--message <text> |
要傳送的行內訊息 |
--message-file <path> |
從有效的 UTF-8 檔案讀取訊息(上限 4 MiB) |
--to <dest> |
從目標(電話、聊天 ID)衍生工作階段金鑰 |
--session-key <key> |
使用明確的工作階段金鑰 |
--agent <id> |
指定已設定的代理程式(使用其 main 工作階段) |
--session-id <id> |
依 ID 重複使用現有工作階段 |
--model <id> |
覆寫此回合的模型(provider/model 或模型 ID) |
--local |
強制使用本機嵌入式執行環境(略過閘道) |
--deliver |
將回覆傳送至聊天頻道 |
--channel <name> |
傳送頻道;與 --agent + --to 搭配時,也會套用私訊範圍 |
--reply-to <target> |
覆寫傳送目標 |
--reply-channel <name> |
覆寫傳送頻道 |
--reply-account <id> |
覆寫傳送帳號 ID |
--thinking <level> |
設定所選模型設定檔的思考層級 |
--verbose <on|full|off> |
將詳細程度保存至工作階段(full 也會記錄工具輸出) |
--timeout <seconds> |
覆寫代理程式逾時(預設為 600 或設定值) |
--json |
輸出結構化 JSON |
行為
- 命令列介面預設會透過閘道執行。加入
--local可強制使用 目前機器上的嵌入式執行環境。 --message或--message-file必須且只能傳入其中一項。移除選用的 UTF-8 BOM 後, 檔案訊息會保留多行內容。超過 4 MiB 的檔案會在派送前遭拒。- 暫時性握手重試後,若閘道逾時或連線關閉,
命令將失敗並在 stderr 顯示提示;命令列介面絕不會靜默地改以
嵌入式環境重新執行該回合。閘道仍可能完成已接受的回合,因此在重試或使用
--local重新執行前, 請先確認閘道與工作階段狀態。 - 工作階段選取:
--to會衍生工作階段金鑰(群組/頻道目標 會維持隔離;直接聊天則會合併至main)。同時使用--agent、--channel與--to時,路由會依循該頻道的標準 收件者與session.dmScope。穩定且僅限傳出的身分會使用 由供應商擁有、與代理程式主要工作階段隔離的工作階段。 --session-key會選取明確的金鑰。以代理程式為前綴的金鑰必須使用agent:<agent-id>:<session-key>,而同時提供兩者時,--agent必須與該代理程式 ID 相符。 若有提供--agent,不含前綴且非哨兵值的金鑰會限定在其範圍內; 例如,--agent ops --session-key incident-42會路由至agent:ops:incident-42。若沒有--agent,不含前綴且非哨兵值的金鑰會限定在 已設定的預設代理程式範圍內。只有在未提供--agent時, 字面值global與unknown才會維持不限定範圍。--reply-channel與--reply-account僅影響傳送。- 思考與詳細程度旗標會保存至工作階段儲存區。
- 輸出:預設為純文字,或使用
--json輸出結構化承載資料與中繼資料。 - 使用
--json --deliver時,JSON 會包含已傳送、 已抑制、部分完成及傳送失敗的傳送狀態。請參閱 JSON 傳送狀態。
範例
# 輸出 JSON 的簡單回合openclaw agent --to +15555550123 --message "追蹤記錄" --verbose on --json # 覆寫模型的回合openclaw agent --agent ops --model openai/gpt-5.4 --message "摘要記錄" # 設定思考層級的回合openclaw agent --session-id 1234 --message "摘要收件匣" --thinking medium # 從檔案讀取多行提示openclaw agent --agent ops --message-file ./task.md # 確切的工作階段金鑰openclaw agent --session-key agent:ops:incident-42 --message "摘要狀態" # 限定於代理程式的舊版金鑰openclaw agent --agent ops --session-key incident-42 --message "摘要狀態" # 傳送至不同於工作階段的頻道openclaw agent --agent ops --message "警示" --deliver --reply-channel telegram --reply-to "@admin"相關內容
Was this useful?