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.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "Session Memory & Summarization" with this command: npx skills add thomasmarcel/session-context

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 <!-- recent_messages_block -->) — 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 <!-- recent_messages_block --> 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

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

🧠 Tiered Recall - 分层回忆系统

分层回忆系统,解决上下文长度限制,保持项目延续性。默认自动加载最近7天记忆,支持手动全量回忆、自定义天数、项目回忆和主题回忆。当前版本采用 slim index,只保留文件名、行号和标题,不存摘要,避免 token 膨胀。

Registry SourceRecently Updated
1780Profile unavailable
General

Amber Hunter

Amber-Hunter is a local AI memory engine that encrypts, stores, and summarizes OpenClaw/Claude sessions and files for instant recall and optional cloud sync.

Registry SourceRecently Updated
4501Profile unavailable
General

Auto Summarization Loop

自动摘要循环:为长对话 AI 角色实现自动上下文管理。用于: (1) 建立多级记忆架构(核心记忆/工作记忆/长期记忆) (2) 实现滑动窗口与双水位线触发策略 (3) 异步后台压缩流程设计 (4) Persona 机器人的结构化摘要输出 适用场景:需要处理长对话、降低 API 成本、避免上下文溢出的 AI 应用

Registry Source
2351Profile unavailable
General

Memory Auto Archive

Automatically archives daily chat logs with keyword highlights and optional AI summaries into organized memory files without manual setup.

Registry SourceRecently Updated
2810Profile unavailable