代理协作
智能体发送
openclaw agent 从命令行运行单个智能体轮次,无需收到入站聊天消息。可用于脚本化工作流、测试和程序化投递。
快速开始
运行一个简单的智能体轮次
openclaw agent --message "What is the weather today?"
这会通过 Gateway 网关发送消息并打印回复。
指定特定智能体或会话
# 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"
将回复投递到渠道
# 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)派生会话键 |
--agent \<id\> |
指定已配置的智能体(使用其 main 会话) |
--session-id \<id\> |
按 ID 复用现有会话 |
--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\> |
覆盖智能体超时时间 |
--json |
输出结构化 JSON |
行为
- 默认情况下,CLI 会通过 Gateway 网关。添加
--local可强制在当前机器上使用嵌入式运行时。 - 如果 Gateway 网关不可达,CLI 会回退到本地嵌入式运行。
- 会话选择:
--to会派生会话键(群组/渠道目标会保持隔离;直接聊天会折叠到main)。 - 思考和详细输出标志会持久化到会话存储中。
- 输出:默认是纯文本,或使用
--json输出结构化载荷 + 元数据。
示例
# 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"