Xpersona
S

Session Memory & Summarization

CLAWHUB · Unverified

Automatically loads recent conversation memory into new sessions and generates AI summaries during compaction to maintain continuity across conversations. Pr... Skill: Session Memory & Summarization Owner: thomasmarcel Summary: Automatically loads recent conversation memory into new sessions and generates AI summaries during compaction to maintain continuity across conversations. Pr... Tags: latest:0.2.0 Version history: v0.2.0 | 2026-04-03T22:16:00.030Z | user v0.2.0: Preserve last 10 raw messages verbatim for exact conversation resumption. Two-layer continuity: AI summary

62
Rank
84
Safety
1.1k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.1K downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s179h2y6xtfhqm5edb0wjxbs75845mnf:session-context
  1. Setup complexity is classified as HIGH. You must provision dedicated cloud infrastructure or an isolated VM. Do not run this directly on your local workstation.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-thomasmarcel-session-context/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

145,869 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: Session Memory & Summarization
slug: session-context
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."
author: "AniBot (Thomas)"
version: "0.2.0"
license: "MIT"
tags:
  - "memory"
  - "session"
  - "summarization"
  - "continuity"
  - "ai"
hooks:
  - "session:start"
  - "session:compact:before"
repository: "https://github.com/animo66/openclaw-skills"
homepage: "https://clawhub.ai/skills/session-context"
minOpenClawVersion: "0.29.0"
---

# 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

```bash
clawhub install session-context
```

Or manually:

```bash
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`:

```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:

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

Adjust summary context size:

```js
// In hooks/session/start/handler.

README.md

# Session Memory & Summarization

Automatically loads recent conversation memory into new sessions and generates AI summaries during compaction to maintain continuity across conversations.

**Two-layer continuity:**
- An **AI summary** gives the agent high-level context from previous sessions
- The **last 10 raw messages verbatim** let it resume exactly mid-conversation — same phrasing, same decisions, same thread

## Features

- **Exact Resumption**: Last 10 raw user/assistant turns are preserved verbatim and reinjected at session start — no paraphrasing loss
- **AI-Powered Summarization**: When approaching token limits, OpenClaw generates a concise AI summary of the conversation
- **Two-Day Context**: On session start, loads today's *and* yesterday's memory so intraday context is never lost
- **Token-Safe**: Summaries capped at 6000 chars; raw messages capped at 1500 chars each — tunable
- **Seamless**: No manual intervention needed

## Installation

### Via ClawHub (recommended)

```bash
clawhub install session-context
```

### Manual

```bash
cd ~/.openclaw/workspace/skills
git clone https://github.com/animo66/openclaw-skills.git tmp-skills
cp -r tmp-skills/session-context .
rm -rf tmp-skills
openclaw skills enable session-context
```

## How It Works

### Session Start Hook

When a new session begins, two context blocks are injected:

1. **AI Summary Block** — distilled summaries from today + yesterday (up to 6000 chars)
2. **Recent Messages Block** — the last 10 user/assistant turns verbatim, so the agent can resume mid-conversation without losing exact phrasing or decisions

### Compaction Hook

When token thresholds are hit (20+ messages or 60% of limit):

1. Generates an AI summary via `agent.generateSummary()`
2. Prepends it to `memory/YYYY-MM-DD.md`
3. Captures the last 10 raw message turns as a JSON block at the end of the file

### Memory File Format

```
memory/
  2026-04-03.md
  2026-04-04.md
  ...
```

Each file looks like:

```markdown
## 22:41:00
<AI summary of the session>

---

## Earlier summary...

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

The `<!-- recent_messages_block -->` marker is always at the end and replaced each compaction with the latest turns.

## Configuration

**Number of raw messages to preserve** (in both handler files):
```js
const MAX_RECENT_MESSAGES = 10;  // last N user/assistant turns
```

**Max summary context injected at session start:**
```js
const MAX_SUMMARY_CHARS = 6000;
```

**Summarization thresholds:**
```js
return (
  msgCount >= 20 ||              // minimum messages
  tokenCount > maxTokens * 0.6   // 60% of token limit
);
```

## Requirements

- OpenClaw 0.29.0 or higher
- `session:start` and `session:compact:before` hook support
- Workspace directory with `memory/` subfolder (created automatically)

## License

MIT

---

**Made with 🤖 by AniBot (Thomas)**

_meta.json

{
  "ownerId": "kn7fhrwqcf9xm6t25veg4sgs19845wps",
  "slug": "session-context",
  "version": "0.2.0",
  "publishedAt": 1775254560030
}

AGENTS.md

# Agent Guidelines for Session Memory Skill

This is an OpenClaw skill that provides automatic conversation memory loading and AI summarization during session compaction.

## Project Structure

```
session-context/
├── SKILL.md                    # Main skill documentation
├── _meta.json                  # Skill metadata (slug, hooks, version)
├── hooks/
│   └── session/
│       ├── start/handler.js     # Loads memory into new sessions
│       └── compact:before/     # Generates summaries before compaction
├── memory/                     # Auto-created; stores daily summaries
└── assets/                     # Templates and resources
```

## Build/Lint/Test Commands

This is a hook-based skill with no build system. Handlers are plain JavaScript/TypeScript executed directly by OpenClaw.

- **No build step required** - Handlers run directly
- **No linting configured** - Write clean ES module code
- **No tests** - Manual testing via OpenClaw hooks

### Manual Testing

1. Enable the skill: `openclaw skills enable session-context`
2. Start a new session to trigger `session:start` hook
3. Check `memory/` directory for generated files
4. Monitor logs for hook execution: `openclaw logs`

## Code Style Guidelines

### General Principles

- Write defensive code with early returns for guard clauses
- Always validate event/context structure before accessing properties
- Use `log.debug()` for flow tracing, `log.info()` for significant events
- Handle errors gracefully - hooks should not crash the session

### JavaScript Handlers

```javascript
import { readFile, writeFile } from 'fs/promises';
import { join } from 'path';

export default async function (context) {
  const { workspace = process.cwd(), log = console } = context;
  
  if (!shouldProceed(context)) {
    return;
  }
  
  try {
    const result = await doSomething(context);
    log.info('Operation completed', { result });
  } catch (error) {
    log.error('Operation failed:', error);
  }
}
```

### Naming Conventions

| Type | Convention | Example |
|------|------------|---------|
| Functions | camelCase | `shouldSummarize`, `writeMemoryFile` |
| Variables | camelCase | `memoryDir`, `latestFile`, `tokenCount` |
| Constants | UPPER_SNAKE | `MAX_TOKENS`, `DEFAULT_THRESHOLD` |
| Types/Interfaces | PascalCase | `HookHandler`, `SessionContext` |
| Files | kebab-case | `session-start`, `compact-before` |

### Imports

```javascript
// Node.js built-ins
import { readFile, writeFile, mkdir } from 'fs/promises';
import { join, basename } from 'path';

// ES modules - no default exports for utilities
// Handlers always use default export
export default async function handler(context) { ... }
```

### Error Handling

```javascript
// For optional operations - catch and continue
const files = await readdir(memoryDir).catch(() => []);

// For required operations - try/catch with logging
try {
  const content = await readFile(filePath, 'utf8');
} catch {
  // File doesn't exist, create it
}

// Always include con

assets/LEARNINGS.md

# Learnings

Corrections, insights, and knowledge gaps captured during development.

**Categories**: correction | insight | knowledge_gap | best_practice
**Areas**: frontend | backend | infra | tests | docs | config
**Statuses**: pending | in_progress | resolved | wont_fix | promoted | promoted_to_skill

## Status Definitions

| Status | Meaning |
|--------|---------|
| `pending` | Not yet addressed |
| `in_progress` | Actively being worked on |
| `resolved` | Issue fixed or knowledge integrated |
| `wont_fix` | Decided not to address (reason in Resolution) |
| `promoted` | Elevated to CLAUDE.md, AGENTS.md, or copilot-instructions.md |
| `promoted_to_skill` | Extracted as a reusable skill |

## Skill Extraction Fields

When a learning is promoted to a skill, add these fields:

```markdown
**Status**: promoted_to_skill
**Skill-Path**: skills/skill-name
```

Example:
```markdown
## [LRN-20250115-001] best_practice

**Logged**: 2025-01-15T10:00:00Z
**Priority**: high
**Status**: promoted_to_skill
**Skill-Path**: skills/docker-m1-fixes
**Area**: infra

### Summary
Docker build fails on Apple Silicon due to platform mismatch
...
```

---

Sponsored

Ads related to Session Memory & Summarization and adjacent AI workflows.