Agent send
openclaw agent 从命令行运行单个 Agent 轮次,而无需传入聊天消息。将其用于脚本化工作流、测试和程序化交付。
运行简单的 agent 轮次
Terminal window openclaw agent --agent main --message "What is the weather today?"```Gateway(网关)这会通过 Gateway(网关) 发送消息并打印回复。指定特定的 agent 或会话
Terminal window # Target a specific agentopenclaw agent --agent ops --message "Summarize logs"# Target a phone number (derives session key)openclaw agent --to +15555550123 --message "Status update"# Reuse an existing sessionopenclaw agent --session-id abc123 --message "Continue the task"# Target an exact session keyopenclaw agent --session-key agent:ops:incident-42 --message "Summarize status"将回复投递到渠道
Terminal window # Deliver to WhatsApp (default channel)openclaw agent --to +15555550123 --message "Report ready" --deliver# Deliver to Slackopenclaw agent --agent ops --message "Generate report" \--deliver --reply-channel slack --reply-to "#reports"
| 标志 | 描述 |
|---|---|
--message \<text\> | 要发送的消息(必填) |
--to \<dest\> | 从目标(电话、聊天 ID)派生会话密钥 |
--session-key \<key\> | 使用显式的会话密钥 |
--agent \<id\> | 指定已配置的 agent(使用其 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\> | 覆盖 agent 超时 |
--json | 输出结构化 JSON |
- 默认情况下,CLI 会通过 Gateway(网关)。添加 CLIGateway(网关)
--local以强制在当前机器上使用嵌入式运行时。 - 如果 Gateway(网关) 无法访问,CLI 将回退到本地嵌入式运行。
- 会话选择:
--to派生会话密钥(群组/渠道目标保持隔离;直接聊天合并为main)。 --session-key选择一个显式密钥。带 Agent 前缀的密钥必须使用agent:<agent-id>:<session-key>,且当两者都提供时,--agent必须与该 agent ID 匹配。裸非哨兵密钥在提供时作用于--agent;例如,--agent ops --session-key incident-42路由到agent:ops:incident-42。如果没有--agent,裸非哨兵密钥将作用于配置的默认 agent。字面量global和unknown仅在未提供--agent时保持无作用域;在这种情况下,嵌入式回退和存储所有权使用配置的默认 agent。- Thinking 和 verbose 标志会持久化到会话存储中。
- 输出:默认为纯文本,或使用
--json获取结构化负载 + 元数据。 - 使用
--json --deliver时,JSON 包含已发送、已抑制、部分发送和失败发送的交付状态。请参阅 JSON delivery status。
# Simple turn with JSON outputopenclaw agent --to +15555550123 --message "Trace logs" --verbose on --json
# Turn with thinking levelopenclaw agent --session-id 1234 --message "Summarize inbox" --thinking medium
# Exact session keyopenclaw agent --session-key agent:ops:incident-42 --message "Summarize status"
# Legacy key scoped to an agentopenclaw agent --agent ops --session-key incident-42 --message "Summarize status"
# Deliver to a different channel than the sessionopenclaw agent --agent ops --message "Alert" --deliver --reply-channel telegram --reply-to "@admin"Agent CLI 参考
完整的 openclaw agent 标志和选项参考。
Sub-agents
后台子 agent 生成。
Sessions
会话密钥的工作原理以及 --to、--agent 和 --session-id 如何解析它们。
Slash commands
在 agent 会话内使用的本机命令目录。