← 返回
未分类 中文

Session Memory & Summarization

Automatically loads recent conversation memory into new sessions and generates AI summaries during compaction to maintain continuity across conversations. Pr...
自动将最近的对话记忆加载到新会话中,并在压缩时生成 AI 摘要,以保持跨会话的连贯性。
thomasmarcel thomasmarcel 来源
未分类 clawhub v0.2.0 1 版本 99815.5 Key: 无需
★ 0
Stars
📥 541
下载
💾 0
安装
1
版本
#latest

概述

Session Memory & Summarization Skill

Provides automatic conversation continuity across sessions by loading recent memory at session start and generating AI summaries during compaction.

What It Does

  • Memory Loading: Injects the latest AI summary AND the last 10 raw message turns verbatim so you resume exactly where you left off
  • AI Summarization: Generates concise summaries when approaching token limits, written to daily memory files
  • Raw Continuity: Stores the last N exact interactions alongside the summary so nothing is lost in translation
  • Seamless Experience: No manual intervention required — just natural conversation flow

Hooks

session:start

Runs when a new session begins. Loads the most recent daily memory file and injects two context blocks:

  1. AI summary block — distilled summaries from today + yesterday (up to 6000 chars)
  2. Recent messages block — last 10 raw user/assistant turns, verbatim, so the AI can resume mid-conversation with exact phrasing and decisions intact

session:compact:before

Runs before automatic compaction (20+ messages OR 60% of token limit). Does two things:

  1. Generates an AI summary via agent.generateSummary() and prepends it to today's memory file
  2. Captures the last 10 user/assistant turns as a JSON block at the end of the file (under ) — this is what session:start reads back next session

Installation

clawhub install session-context

Or manually:

cd ~/.openclaw/workspace/skills
git clone https://github.com/thomasmarcel/openclaw-skill-session-context.git session-context
openclaw skills enable session-context

Requirements

  • OpenClaw ≥ 0.29.0
  • Workspace with memory/ directory (created automatically)
  • Access to agent's LLM for summarization

Configuration

Customize thresholds in hooks/session/compact:before/handler.js:

return (
  msgCount >= 20 ||           // minimum messages before summarizing
  tokenCount > maxTokens * 0.6 // trigger at 60% of token limit
);

Adjust how many raw messages to preserve:

// In both handler files:
const MAX_RECENT_MESSAGES = 10;  // last N user/assistant turns to preserve verbatim

Adjust summary context size:

// In hooks/session/start/handler.js:
const MAX_SUMMARY_CHARS = 6000;  // cap on AI summary injected at session start

Memory Structure

memory/
  2026-04-03.md  # daily files — summaries at top, recent_messages block at bottom
  2026-04-04.md

Each file has this structure:

## HH:MM:SS
<AI summary of the session>

---

## Earlier timestamp
<earlier summary>

<!-- recent_messages_block -->
[{"role":"user","content":"..."},
 {"role":"assistant","content":"..."},
 ...]

The section is always at the end and replaced each compaction with the latest N turns.

How It Works

  1. During a conversation: As token usage grows, OpenClaw monitors session size.
  2. Before compaction: The session:compact:before hook checks thresholds. If met:
    • Generates an AI summary and prepends it to memory/YYYY-MM-DD.md
    • Captures the last 10 raw message turns as a JSON block at the end of the file
  3. Compaction proceeds: Older messages are pruned.
  4. Next session: The session:start hook loads the file and injects both:
    • The AI summary (for high-level context)
    • The raw recent messages (to resume exactly where you left off)

License

MIT

版本历史

共 1 个版本

  • v0.2.0 当前
    2026-05-03 06:51 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

Find Skills

guipi888
场景驱动+关键词双模式技能发现工具。当用户用自然语言描述场景/需求(如"我想做一个海报""帮我分析股票"),或明确说"安装技能/find skills/找个skill"时,自动从官方内置、本地已安装、SkillHub、虾评、GitHub、C
★ 1,466 📥 532,079
ai-agent

Agent Browser

rez0
用于 AI 代理的浏览器自动化 CLI。当用户需要与网站交互(包括浏览页面、填写表单、点击按钮、截图等)时使用。
★ 836 📥 312,678
ai-agent

self-improving agent

pskoett
捕获经验教训、错误及修正内容,以实现持续改进。适用于以下场景:(1)命令或操作意外失败;(2)用户纠正Claude(如“不,那不对……”“实际上……”);(3)用户请求的功能不存在;(4)外部API或工具出现故障;(5)Claude发现自身
★ 4,101 📥 828,886