概述

openclaw agent 命令从命令行运行单次 Agent turn,无需入站聊天消息。适用于脚本工作流、测试和程序化投递。

核心功能

  • 默认通过 Gateway 执行,Gateway 不可达时回退到本地嵌入式运行时
  • 支持目标 Agent、会话 ID、电话号码等多种会话选择方式
  • 可选将回复投递到聊天频道(--deliver)
  • 支持 --json 输出结构化结果(含投递状态)
  • --thinking 和 --verbose 标志持久化到会话存储

常用标志

标志说明
--message <text>发送的消息(必填)
--to <dest>从目标(电话、chat id)推导会话 key
--agent <id>目标配置的 Agent(使用其 main 会话)
--session-id <id>复用已有会话
--local强制本地嵌入式运行时
--deliver将回复发送到聊天频道
--channel <name>投递频道(whatsapp/telegram/discord/slack 等)
--thinking <level>设置 thinking 级别
--json输出结构化 JSON

使用示例

# 简单 Agent turn
openclaw agent --message "What is the weather today?"
 
# 目标特定 Agent
openclaw agent --agent ops --message "Summarize logs"
 
# 投递到 Slack
openclaw agent --agent ops --message "Generate report" \
  --deliver --reply-channel slack --reply-to "#reports"
 
# JSON 输出
openclaw agent --to +15555550123 --message "Trace logs" --verbose on --json

相关页面

  • concepts/tool-subagents — Sub-agents(Agent 内部派生后台运行)
  • session — 会话 key 工作原理
  • concepts/tool-acp-agents — ACP agents(外部 harness 运行时)