Automatically loads recent conversation memory into new sessions and generates AI summaries during compaction to maintain continuity across conversations.
- Automatic Memory Loading: Each new session automatically loads the latest memory file (today's or yesterday's) to provide immediate context
- AI-Powered Summarization: When approaching token limits, OpenClaw automatically generates a concise AI summary of the conversation
- Seamless Continuity: No manual intervention needed — memory persists across sessions and devices
- Token-Safe: Content truncated to ~4000 characters to protect context window
clawhub install session-contextcd ~/.openclaw/workspace/skills
git clone https://github.com/thomasmarcel/openclaw-skill-session-context.git session-context
openclaw skills enable session-contextWhen a new session begins:
- Skill finds the most recently modified
.mdfile in thememory/directory - Loads its content as a system message into the session context
- If no memory exists yet, starts fresh
This ensures continuity: yesterday's important context is automatically available today.
OpenClaw automatically compacts sessions before hitting token limits. When triggered:
- Hook checks if summarization thresholds are met (20+ messages OR 60% of token limit)
- Calls
agent.generateSummary(messages)to produce an AI-generated summary - Prepends the summary to today's memory file in
memory/YYYY-MM-DD.mdwith a timestamp - Session is compacted, freeing tokens while preserving key information
- Daily files:
memory/2025-04-03.md,memory/2025-04-04.md, etc. - Each file accumulates summaries throughout the day, newest first
- No global
MEMORY.mdis needed (but yoursession:starthook can load it if you prefer)
The skill uses sensible defaults, but you can customize:
Summarization thresholds (in hooks/session/compact:before/handler.js):
return (
msgCount >= 20 || // minimum messages to summarize
tokenCount > maxTokens * 0.6 // trigger at 60% of token limit
);Content truncation (in hooks/session/start/handler.js):
const truncated = content.substring(0, 4000); // adjust as needed- OpenClaw 0.29.0 or higher
session:startandsession:compact:beforehook support- Workspace directory with
memory/subfolder (created automatically)
MIT
This skill is designed to be generic and useful to all OpenClaw users. Feel free to fork, improve, and submit PRs to the upstream repository.
Made with 🤖 by AniBot (Thomas)