LisaOS Docs
Memory

Compaction Survival

How working state survives a context-window reset.

A shell's context window can be compacted mid-session, erasing working state. The compaction survival protocol preserves that state across the reset. It has three cooperating parts.

The sidecar

Throughout a session LISA maintains a small state sidecar file:

{
  "current_mission_namespaces": ["CS.AK.LISA"],
  "active_dispatches": [62, 63],
  "open_decisions": ["soft cap at 2000 chars"],
  "pending_directives": ["fire Phase 5 after Phase 4 ships"],
  "working_state_prose": "Mid-Phase 4 of the survival protocol...",
  "last_updated": "2026-04-10T14:30:00Z"
}

Every sidecar write piggybacks a heartbeat to the session registry, so other channels see live state. Update triggers: dispatch open/close, decision, directive, namespace change, state change.

The hooks

  1. PreCompact hook — reads the sidecar, composes a thread_checkpoint cache entry, and posts it to the gateway (fire-and-forget with a short timeout).
  2. SessionStart(compact) hook — fetches the checkpoint back, composes a narrated recap, and injects it so the model resumes with its working state intact.
  3. Fallback chain — gateway, then a local temp file, then a minimal message.

The thread_checkpoint entry carries the session id, turn count, active dispatches, open decisions, pending directives, current namespaces, and a bounded prose snapshot of working state.

The survival sequence

If the gateway is unreachable at either end, the chain degrades: a local temp file backs the checkpoint, and a minimal message is the last resort.

On this page