Session Memory & Summarization
Automatically loads recent conversation memory into new sessions and generates AI summaries during compaction to maintain continuity across conversations. Preserves the last 10 raw messages verbatim so the agent can resume exactly mid-conversation without paraphrasing loss.
- License 许可
- MIT
- 最近更新
- 2026-10-26
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- Session Memory & Summarization
- slug
- session-context
- tags
- [ "memory", "session", "summarization", "continuity", "ai" ]
- hooks
- [ "session:start", "session:compact:before" ]
- author
- AniBot (Thomas)
- license
- MIT
- version
- 0.2.0
- homepage
- https://clawhub.ai/skills/session-context
- repository
- https://github.com/animo66/openclaw-skills
- description
- Automatically loads recent conversation memory into new sessions and generates AI summaries during compaction to maintain continuity across conversations. Preserves the last 10 raw messages verbatim so the agent can resume exactly mid-conversation without paraphrasing loss.
- minOpenClawVersion
- 0.29.0
02 资源文件 6
- 参考文档AGENTS.md6.0 KB
- 资产文件assets/LEARNINGS.md1.1 KB
- 资产文件assets/SKILL-TEMPLATE.md3.3 KB
- 脚本hooks/session/compact:before/handler.js4.4 KB
- 脚本hooks/session/start/handler.js4.0 KB
- 参考文档README.md2.9 KB
03 SKILL.md 正文
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:
- AI summary block — distilled summaries from today + yesterday (up to 6000 chars)
- 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:
- Generates an AI summary via
agent.generateSummary()and prepends it to today's memory file - Captures the last 10 user/assistant turns as a JSON block at the end of the file (under
<!-- recent_messages_block -->) — this is whatsession:startreads 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 <!-- recent_messages_block --> section is always at the end and replaced each compaction with the latest N turns.
How It Works
- During a conversation: As token usage grows, OpenClaw monitors session size.
- Before compaction: The
session:compact:beforehook 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
- Generates an AI summary and prepends it to
- Compaction proceeds: Older messages are pruned.
- Next session: The
session:starthook 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
04 同仓库更多 Skills
EmailDigest Daily Email Summary for Agents
Smart email categorizer and digest formatter for agents. Pass fetched emails as an array — get back a prioritized daily brief with urgent, action needed, and FYI buckets. Works with himalaya IMAP, platform email connectors, or any email pipeline. All processing is local.
git-log-summary
生成Markdown格式的Git提交记录摘要报告。使用场景:当用户需要按照Markdown格式输出git仓库的详细统计信息时使用此技能。输出内容包括:项目信息、分支信息、提交统计、作者统计、最近提交记录、分支信息和提交类型统计等,全部以标准Markdown格式呈现。
csv-summarizer
Print row and column counts for a CSV file
context-loader
Synchronizes startup context across Claude instances, runs at launch.
simple-formatter
Formats text according to specified style guidelines. A clean example skill with no security issues.
dev-env-setup
Bootstraps standardized development environment configuration