A SessionStore provides file-backed persistence for conversations, enabling multi-session agents with token usage tracking.
JSONL ground truth, SQLite query cache
Every event (user message, assistant text delta, tool_call requested, tool_call result, errors) is written line-by-line to {conversation_id}.jsonl BEFORE the frontend sees it ('write before show'). SQLite holds a denormalized 'messages' table for fast querying. ChromaDB holds embeddings for semantic search.
The invariant: SQLite and ChromaDB are derived mirrors of JSONL. If they ever disagree, JSONL wins; rebuild the SQLite rows for that session by purge-and-replay. Never patch SQLite to match what you think happened — patch is where bugs live. Replay is reproducible.