Skip to content
广告 · 本站推荐广告

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>输出格式:textjsonmarkdowntext
--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"

相关命令

基于MIT协议开源 | 内容翻译自 官方文档,同步更新