vtcode-session-store
Unified per-session state store for VT Code — the single source of truth for an agent session's state, context, and history.
Each session is persisted under .vtcode/sessions/<session_id>/:
events.jsonl— the canonical append-onlyThreadEventlog (schema-versioned viaVersionedThreadEvent). Everything else is derived from this.manifest.json— session metadata and counters.index/turns.json— byte-offset index enabling O(1) turn reconstruction.derived/— regenerated views (trajectory.jsonl,memory.json, …).
Design
- Append-only + off the hot path. The live conversation stays in memory and is never reloaded from disk into context. Reads happen only for revert, compaction, analytics, and long-term-learning queries.
- Single source of truth. Checkpoints, trajectory metrics, and session
memory are derived from
events.jsonlrather than persisted independently, eliminating the redundant.vtcode/checkpoints,.vtcode/logs, and.vtcode/historystores. - Bounded growth.
apply_retentionevicts the oldest/stale sessions so disk overhead does not accumulate across a long-lived agent.
Usage
use ;
// Record a session's events (call from the runloop's event sink).
let log = open?;
log.append?;
let turn = log.reconstruct_turn?; // derived view, never into context
// One-off migration of the legacy overlapping stores.
let report = migrate_legacy?;
// Bound growth and learn across sessions.
apply_retention?;
let facts = query_facts?;
Modules
event_log— append-only log, turn index, manifest.migration— import legacy history/trajectory stores.retention— retention policy + garbage collection.query— cross-session analytics and long-term-learning queries.