openclaw sessions
管理对话会话。
概要
bash
openclaw sessions <子命令> [选项]描述
openclaw sessions 命令用于管理 OpenClaw 的对话会话。每次与 Agent 的交互都会创建一个会话,会话包含完整的消息历史、使用的模型和技能信息。此命令可以查看、检索、导出和删除会话记录。
子命令
| 子命令 | 说明 |
|---|---|
list | 列出所有会话 |
view <key> | 查看指定会话的消息历史 |
delete <key> | 删除指定会话 |
export <key> | 导出会话为文件 |
clear | 清除所有会话 |
选项
| 选项 | 缩写 | 说明 | 默认值 |
|---|---|---|---|
--channel <name> | -c | 按通道过滤 | 全部 |
--limit <n> | -n | 限制返回数量 | 50 |
--since <time> | 筛选指定时间之后的会话 | - | |
--format <type> | 输出格式:text、json、markdown | text | |
--verbose | -v | 显示详细信息 | false |
会话 Key 格式
会话 Key 由通道类型和唯一标识组成:
whatsapp:+8613800001234
telegram:@username
wechat:wxid_abc123
cli:session_001输出示例
$ openclaw sessions list
┌─────────────────────────────┬──────────┬──────┬─────────────────────┐
│ 会话 Key │ 通道 │ 消息数│ 最后活动 │
├─────────────────────────────┼──────────┼──────┼─────────────────────┤
│ whatsapp:+8613800001234 │ whatsapp │ 42 │ 2026-03-05 10:30 │
│ cli:session_001 │ cli │ 15 │ 2026-03-05 09:20 │
│ telegram:@user_test │ telegram │ 8 │ 2026-03-04 18:00 │
└─────────────────────────────┴──────────┴──────┴─────────────────────┘示例
bash
# 列出所有会话
openclaw sessions list
# 查看某个会话的消息记录
openclaw sessions view "whatsapp:+8613800001234"
# 按通道过滤会话
openclaw sessions list --channel telegram
# 导出会话为 Markdown
openclaw sessions export "cli:session_001" --format markdown
# 删除指定会话
openclaw sessions delete "cli:session_001"
# 清除所有会话
openclaw sessions clear --yes
# 查看最近 24 小时的会话
openclaw sessions list --since "24h"相关命令
openclaw message- 发送消息openclaw memory- 记忆管理openclaw reset- 重置
