介绍 OpenClaw 的 Session 机制,包括如何保持对话上下文、Session 生命周期管理、以及在不同对话间切换的方法。
Session 是 OpenClaw 中管理对话上下文的核心机制,确保 Agent 能记住之前的对话内容。
创建 → 活跃 → 休眠 → 恢复 → 结束
openclaw sessions list
openclaw sessions switch <session-id>
在 openclaw.yaml 中启用:
agents:
my-agent:
memory:
enabled: true
storage: local
openclaw sessions cleanup --older-than 7d
Session 是管理对话上下文的核心机制,确保 Agent 能记住之前的对话内容。
在 openclaw.yaml 中,将 agents 下的 memory.enabled 设置为 true 并指定存储方式(如 local)。
使用命令 openclaw sessions switch <session-id> 即可切换到指定会话。
使用命令 openclaw sessions cleanup --older-than 7d 可以清理 7 天前的会话。
人类专家验证
官方机器人验证