Flows category icon
Memory & Context
Intermediate

Session Summaries That Survive Compaction

Write durable session summaries at the right moments so knowledge outlives compaction and process restarts.

4 steps12 verify checks60-90 minutesWorks with: emergent · chatgpt · claude · cursor
Start Guided Walkthrough

The Route

0/4 verified

Context Pack

Paste this first. It briefs the AI on requirements, constraints, and the Definition of Done before your first build prompt.

Context Pack
PROJECT CONTEXT:
Compaction and restarts keep eating knowledge my agent already earned: what worked, what failed, what the user prefers. Memory research calls compaction the moment memories die - unless you write summaries designed to survive it.

GOAL:
Add a durable session-summary layer: written at session end and before compaction, stored outside the context, and reloaded into future sessions.

REQUIREMENTS:
- A session summary written to disk at session end and immediately before every compaction
- Summary content: outcomes, working commands, failed approaches, user preferences, project facts
- Summaries stored per project, outside the conversation context
- New sessions load the latest summary (or a digest of recent ones) at start
- A size cap with oldest-first pruning so the store stays lean

CONSTRAINTS:
- Summaries capture durable knowledge, not conversational blow-by-blow
- Failed approaches are first-class content - they prevent repeated mistakes

DEFINITION OF DONE:
- Killing a session and starting fresh, the agent knows the project state and past decisions
- A previously-failed approach is not retried blindly in a new session
- Summary files stay under the size cap across 10+ sessions
- Pre-compaction summaries capture the about-to-be-compacted knowledge

COMMON FAILURES TO AVOID:
- Summaries written only on clean exit, so crashes lose everything
- Transcript-shaped summaries that are as long as what they summarize
- Never loading the summaries back, making the whole layer decorative
- Unbounded accumulation until the summary store itself needs compaction

Paste this into your AI builder first. It teaches the AI what you want before you give it the build prompt.

Related routes

More Memory & Context flows that share ground with this one.

Flows category icon
Memory & Context

Add File-Based Persistent Memory

Give your agent durable memory with plain files - the radical-minimalism approach production practitioners keep converging on.

01Design the memory file structure
02Load memory at session start
03Build the guarded memory_update tool

+1 more steps to Done

Best foryour first pass at this - no prior setup assumed

4 steps45-75 minutesBeginner
Flows category icon
Memory & Context

Cross-Session Project State

Keep long-horizon work coherent across many sessions: externalized project state that any session can load, advance, and hand off.

01Design the project-state document
02Implement the session-start protocol
03Implement the session-end advance

+1 more steps to Done

Best forproduction-grade builds with strict verification

4 steps90-120 minutesAdvanced
Flows category icon
Memory & Context

Implement Context Compaction

Keep long agent sessions alive by compacting old conversation into structured summaries before the context window fills.

01Add token accounting
02Design the structured summary format
03Implement the compaction operation

+1 more steps to Done

Best forproduction-grade builds with strict verification

4 steps90-120 minutesAdvanced

Made with Emergent