My AI agents' shared memory now sleeps on its own, and stopped losing conversations
Description and use
Automatic sleep in Agent Brain Hub prevents loss of early messages in long conversations, consolidates memory, and avoids unexpected billing.
Problem
Working memory kept only the last 40 turns, so after 30 back‑and‑forth messages without a manual sleep, the first 10 turns were lost and never consolidated into long‑term memory.
Outcome
Automatic sleep prevents loss of early conversation turns, consolidates memory, and avoids surprise billing by staggering summarization calls.
Workflow
- 1. Detect trigger: if turns >= cfg.maxPendingTurns → pressure; else if idleMinutes >= cfg.idleMinutes → idle; else null.
- 2. Run sleep cycle when trigger is not null.
- 3. Consolidate conversations into long‑term memory and forget expired facts.
- 4. Update brain view with note explaining why sleep occurred.
Evidence
Working memory keeps only the last 40 turns. After 30 back‑and‑forth messages with nobody pressing the button, the first 10 questions were simply gone.
The core check is small: const trigger = turns >= cfg.maxPendingTurns ? 'pressure' : idleMinutes >= cfg.idleMinutes ? 'idle' : null;
Manual and automatic sleeps share one queue, so two runs never touch memory at the same time.
- Record date: 2026-10-07T16:41:08.803Z