Auto-sync memory files on session end with size management

Resolved 💬 6 comments Opened Feb 26, 2026 by tcusolle Closed May 2, 2026

Problem

When a session ends (IDE closed, terminal closed, /exit), any work completed during that session is lost from memory unless the AI proactively wrote to memory files mid-session. This means the next session starts with stale or incomplete context, leading to:

  • Forgetting what was accomplished (suggesting work that's already done)
  • Stale "next steps" that no longer apply
  • User having to re-explain project state
  • Erosion of trust in the memory system

This is the default experience for most users since there's no prompt or mechanism to trigger a memory update before session teardown.

Additionally, without size management, memory files will grow unbounded over long-lived projects, increasing context consumption and degrading inference quality.

Proposed solution

1. Auto-sync on session end

On session end, automatically:

  1. Diff the work performed (files changed, tasks completed, key decisions) against current memory files
  2. Update memory with: completed work, current project state, and logical next steps
  3. Keep it concise — append/update, don't rewrite everything

This could be implemented as a built-in session-end hook, enabled by default, with an opt-out setting.

2. Memory size management

To prevent unbounded growth, implement a configurable eviction strategy:

  • Size cap: default limit (e.g., 200 lines / 10KB for MEMORY.md) configurable via settings
  • Eviction strategy: when the cap is hit during a sync, the AI should:
  • Summarize and consolidate — merge older granular entries into higher-level summaries (e.g., 10 session entries about auth work become "Implemented full auth system with JWT, middleware, and tests")
  • Promote to topic files — move detailed notes to separate files (e.g., auth-history.md) and keep a one-line link in MEMORY.md
  • Drop stale entries — remove items that are no longer relevant (completed TODOs, resolved open questions, superseded decisions)
  • Priority retention: recent entries, user preferences, and architectural decisions should be evicted last
  • Transparency: when entries are evicted or consolidated, note what was removed so the user can recover if needed (e.g., git history or an archive.md)

This mirrors how human note-taking works — you keep a concise summary page and archive the details elsewhere.

Why this should be default

  • Users don't think about memory management — they expect continuity
  • The AI already has the context at session end; it just doesn't persist it
  • The cost is low (one write operation) and the value is high (seamless multi-session workflows)
  • Current workaround (user explicitly asking "update your memory") is fragile and unintuitive
  • Without size management, the feature becomes self-defeating — bloated memory slows down the very inference it's meant to help

View original on GitHub ↗

This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗