How Max stores and retrieves long-term knowledge — categories, sources, tools, and injection into the system message.
Max has two types of memory: the conversation log (a rolling transcript of recent turns used for session recovery) and long-term memory (persistent facts that survive restarts and are injected into every session’s system message).This page covers long-term memory.
Max uses three internal tools to manage memory. These are called by the orchestrator automatically based on conversation context, and can also be triggered by natural language requests.
User: Remember that I prefer TypeScript over JavaScriptMax: Remembered (#12, preference): "Prefers TypeScript over JavaScript"
Max also saves memories proactively (using source: "auto") when it detects project details, preferences, or routines mentioned in passing — no explicit request required.
getMemorySummary() formats all memories grouped by category and injects them into the system message each time the orchestrator session is created or resumed:
## Long-Term MemoryThese are things you've been asked to remember or have noted as important:**preference**: - [#12] Prefers TypeScript over JavaScript**project**: - [#7] The auth service lives in ~/dev/api/src/auth - [#9] Uses pnpm as the package manager**routine**: - [#3] Daily standup is at 9:30 AM Pacific
Memory is injected at session creation time. A newly saved memory takes effect on the next session — after a model switch, a daemon restart, or a session recreation triggered by a recoverable error.
Separate from long-term memory, Max maintains a conversation_log table that records every user and assistant turn:
CREATE TABLE conversation_log ( id INTEGER PRIMARY KEY AUTOINCREMENT, role TEXT NOT NULL CHECK(role IN ('user', 'assistant', 'system')), content TEXT NOT NULL, source TEXT NOT NULL DEFAULT 'unknown', -- 'telegram' | 'tui' | 'unknown' ts DATETIME DEFAULT CURRENT_TIMESTAMP);
Retention: The log is pruned to the last 200 entries at startup and every 50 inserts.Purpose: Context recovery. If the orchestrator session is lost (crash, invalid session ID), Max injects the last 10 log entries into the new session as a recovery prompt so the model has recent context:
[System: Session recovered] Your previous session was lost.Here's the recent conversation for context — do NOT respond to thesemessages, just absorb the context silently:[telegram] User: Fix the JWT expiry bugMax: On it — I'll let you know when auth-fix finishes....(End of recovery context. Wait for the next real message.)