一句话定义

  • 这一组命令负责直接调用 agent、查看和管理会话、使用记忆搜索,以及处理 ACP 等与 agent 交互相关的能力。

解决的问题

  • 不经过聊天平台,怎么直接在终端里让 agent 干活
  • 当前有哪些会话,哪些最近活跃
  • 如何查 MEMORY.md 与 daily memory 的语义索引状态
  • 如何重建记忆索引
  • 如何通过 ACP 连接外部 IDE 或工具

核心机制

  • agent:发起一次 agent turn。
  • agents:管理隔离 agent(workspace、auth、routing)。
  • sessions:查看会话(新增 cleanup、export-trajectory)。
  • memory:记忆索引、重建、搜索(新增 promote、promote-explain、rem-backfill、rem-harness)。
  • tasks:检视持久后台任务和 TaskFlow 状态(v2026.5.26 新增)。
  • transcripts:检视已存储的 transcripts(v2026.5.26 新增)。
  • system:system event / heartbeat / presence,属于系统级交互配套能力。

关键组成

1. 直接调用 agent

openclaw agent --message "今天天气怎么样?"
openclaw agent --message "分析这段代码" --thinking medium
openclaw agent --to +15555550123 --message "Run summary" --deliver

适合场景:

  • 在终端直接做一次请求
  • 继续某个特定 session
  • 生成结果后直接投递到目标频道

2. 管理隔离 agent

openclaw agents list
openclaw agents add <name>
openclaw agents delete <id>
openclaw agents bindings
openclaw agents bind --agent <id> --bind telegram

适合场景:

  • 多个独立 workspace / 多套模型路由
  • 按频道或账号做路由隔离

3. 会话管理

openclaw sessions
openclaw sessions --active 120
openclaw sessions --json
openclaw sessions cleanup
openclaw sessions export-trajectory

适合场景:

  • 看有哪些会话存在
  • 看最近活跃会话
  • 给脚本或自动化做 JSON 输出
  • cleanup:会话存储运维清理(v2026.5.26 新增)
  • export-trajectory:导出 trajectory bundle(v2026.5.26 新增)

4. 记忆系统

openclaw memory status
openclaw memory status --deep
openclaw memory index
openclaw memory index --force
openclaw memory search "meeting notes"
openclaw memory promote --limit 10 --min-score 0.75
openclaw memory promote --apply
openclaw memory promote-explain "关键词"
openclaw memory rem-harness --json
openclaw memory rem-backfill --path ./memory

适合场景:

  • 检查记忆索引是否可用
  • 强制重建索引
  • 基于语义搜索历史记忆
  • promote:将短期记忆提升为长期记忆(v2026.5.26 新增 REM 机制)
  • promote-explain:解释特定候选的提升分数(v2026.5.26 新增)
  • rem-backfill:写回历史 REM 摘要到 DREAMS.md(v2026.5.26 新增)
  • rem-harness:预览 REM 反射和候选真值(v2026.5.26 新增)

5. Tasks、Transcripts 与系统级交互(v2026.5.26 新增)

openclaw tasks list
openclaw tasks show <id>
openclaw tasks cancel <id>
openclaw tasks flow
openclaw tasks audit
openclaw tasks maintenance
openclaw tasks notify
openclaw transcripts list
openclaw transcripts show <id>
openclaw transcripts path <id>
openclaw system event --text "hello"
openclaw system heartbeat last
openclaw system presence

说明:

  • tasks 用于检视持久后台任务和 TaskFlow 状态(v2026.5.26 全新)
  • transcripts 用于检视已存储的 transcripts(v2026.5.26 全新)
  • system 偏向底层系统交互与心跳管理

生命周期 / 执行流程

做一次终端 agent 调用

  1. openclaw agent --message "..."
  2. 若需要渠道投递,加 --deliver--channel--to
  3. 如果想复用上下文,可指定 session 相关参数

查历史与记忆

  1. openclaw sessions --active 120
  2. openclaw memory status
  3. openclaw memory search "..."
  4. 新增记忆文件后必要时 openclaw memory index

排查“记忆为什么搜不到”

  1. openclaw memory status
  2. openclaw memory status --deep
  3. openclaw memory index --force
  4. 确认 embedding provider / memory 文件结构是否正常

高频命令组合

直接问 agent

openclaw agent --message "帮我总结今天日志"

看活跃会话 + 查记忆

openclaw sessions --active 120
openclaw memory search "上次讨论的服务器配置"

强制重建记忆索引

openclaw memory status
openclaw memory index --force

边界与限制

  • agent 是一次性调用入口,不等于完整多轮消息平台体验。
  • sessions 主要是查看与枚举;具体对话能力更多还是通过 agent / 平台侧进行。
  • memory search 依赖 embedding / index 正常工作,provider 异常时会不可用。
  • agents 管理的是隔离 agent,而不是简单会话别名。

常见误区

  • 误区 1:把 agentmessage send 混为一谈。前者是让 AI 干活,后者是发消息。
  • 误区 2:以为新增记忆文件就会自动立即可搜索。很多场景仍需要 memory index
  • 误区 3:把 agentssessions 当同一层概念。前者偏运行实体,后者偏对话上下文。

对比项

  • agent:发起一次 agent turn
  • agents:管理隔离 agent
  • sessions:列出会话
  • memory:索引与搜索记忆
  • system:心跳、事件、presence