memory: auto-summarize session into memory.jsonl on :q (cross-session distillation) #102

Closed
opened 2026-05-17 09:15:39 +00:00 by claude-noether · 0 comments
Collaborator

Motivation

Today :memory summarize is a manual meta — users have to remember to run it before quitting, or the session's insights are lost. Phase 4's memory.jsonl + startup-context injection provides the persistence + recall, but the in-flow is gated on user action.

The German analysis 2026-05-17 strategy 5 ("History-Zusammenfassung via local", 3h, medium ROI, location: history.lua-shaped module) called this out as a small-local-model improvement: every session should produce a digest that the NEXT session's [background] memory block can use to skip rediscovery.

Proposal

memory = {
  enabled = true,
  -- new:
  auto_summarize_on_quit  = true,
  min_turns_for_summary   = 5,       -- skip trivial sessions
  summary_model           = "fast",  -- defaults to cfg.context.summarizer_model
}

Wires the existing :memory summarize distill flow (repl.lua ~1770) into shutdown_session. On :q with auto_summarize_on_quit=true and turn count above threshold, fire one broker.chat against summary_model asking for 1-3 memory items, append to memory.jsonl. Failure is silent (don't block shutdown).

Composition

  • Reuses the existing distill prompt + JSON parse path from :memory summarize.
  • Composes with the proposed FR-A: ctx.summary captured during session can be appended to the distill input to give the model better context.
  • No surprise cost: gate on flag default false.

Acceptance

  • aish session > 5 turns, :q triggers a brief preplan-style status "summarizing session for memory...", produces 1-3 lines in memory.jsonl.
  • Next session startup shows the new entries in the [background] block.
  • aish session with 2 turns + :q does NOT trigger summarize (below threshold).
  • shutdown_session must remain robust if summarize fails (broker down, parse fail).

Effort

~3h. Mostly extracting the :memory summarize body into a callable + wiring into shutdown_session + adding the cfg gate.

## Motivation Today `:memory summarize` is a manual meta — users have to remember to run it before quitting, or the session's insights are lost. Phase 4's memory.jsonl + startup-context injection provides the persistence + recall, but the in-flow is gated on user action. The German analysis 2026-05-17 strategy 5 ("History-Zusammenfassung via local", 3h, medium ROI, location: history.lua-shaped module) called this out as a small-local-model improvement: every session should produce a digest that the NEXT session's [background] memory block can use to skip rediscovery. ## Proposal ```lua memory = { enabled = true, -- new: auto_summarize_on_quit = true, min_turns_for_summary = 5, -- skip trivial sessions summary_model = "fast", -- defaults to cfg.context.summarizer_model } ``` Wires the existing `:memory summarize` distill flow (repl.lua ~1770) into `shutdown_session`. On `:q` with `auto_summarize_on_quit=true` and turn count above threshold, fire one broker.chat against `summary_model` asking for 1-3 memory items, append to memory.jsonl. Failure is silent (don't block shutdown). ## Composition - Reuses the existing distill prompt + JSON parse path from `:memory summarize`. - Composes with the proposed FR-A: ctx.summary captured during session can be appended to the distill input to give the model better context. - No surprise cost: gate on flag default false. ## Acceptance - aish session > 5 turns, :q triggers a brief preplan-style status "summarizing session for memory...", produces 1-3 lines in memory.jsonl. - Next session startup shows the new entries in the [background] block. - aish session with 2 turns + :q does NOT trigger summarize (below threshold). - shutdown_session must remain robust if summarize fails (broker down, parse fail). ## Effort ~3h. Mostly extracting the `:memory summarize` body into a callable + wiring into shutdown_session + adding the cfg gate.
Sign in to join this conversation.