Appearance
Agent Send
openclaw agent 无需入站聊天消息即可从命令行运行单次 agent 轮次,适合脚本工作流、测试和程序化投递。
快速上手
第一步:运行简单的 agent 轮次
bash
openclaw agent --message "今天天气怎么样?"这条命令通过 Gateway 发送消息并打印回复。
第二步:指定 agent 或会话
bash
# 指定 agent
openclaw agent --agent ops --message "汇总日志"
# 指定手机号(派生会话 key)
openclaw agent --to +15555550123 --message "状态更新"
# 复用已有会话
openclaw agent --session-id abc123 --message "继续任务"第三步:将回复投递到频道
bash
# 投递到 WhatsApp(默认频道)
openclaw agent --to +15555550123 --message "报告就绪" --deliver
# 投递到 Slack
openclaw agent --agent ops --message "生成报告" \
--deliver --reply-channel slack --reply-to "#reports"标志参数
| 标志 | 说明 |
|---|---|
--message <text> | 要发送的消息(必填) |
--to <dest> | 从目标(手机号、聊天 ID)派生会话 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> | 设置思考级别(off、minimal、low、medium、high、xhigh) |
--verbose <on|full|off> | 设置详细级别 |
--timeout <seconds> | 覆盖 agent 超时时间 |
--json | 输出结构化 JSON |
行为说明
- 默认情况下,CLI 经由 Gateway 工作。添加
--local可强制在当前机器上使用嵌入式运行时。 - 如果 Gateway 不可达,CLI 自动回退到本地嵌入式运行。
- 会话选择:
--to派生会话 key(群组/频道目标保持隔离;直接对话折叠为main)。 - 思考和详细标志持久化到会话存储。
- 输出:默认纯文本,加
--json获取结构化载荷 + 元数据。
使用示例
bash
# 简单轮次,JSON 输出
openclaw agent --to +15555550123 --message "追踪日志" --verbose on --json
# 带思考级别的轮次
openclaw agent --session-id 1234 --message "汇总收件箱" --thinking medium
# 投递到与会话不同的频道
openclaw agent --agent ops --message "告警" --deliver --reply-channel telegram --reply-to "@admin"相关文档
- Agent CLI 参考
- Sub-agents — 后台子 agent 启动
- Sessions — 会话 key 的工作原理