swink-agent-memory
Session persistence and context management for swink-agent — durable conversation storage, recoverable checkpoints, and summarization-based compaction.
Features
JsonlSessionStore— append-only JSONL session storage with atomic writes and a resumable sequence counterFileCheckpointStore— durable agent-state checkpoints between turns (for crash recovery and mid-run inspection)SummarizingCompactor— LLM-driven context compaction that preserves recent turns and summarizes older onesSessionMigrator— forward-compatible session schema migration with versioned meta headersInterruptState/PendingToolCall— capture in-flight tool calls across restartsBlockingSessionStore— sync wrapper for non-async callersformat_session_id()produces sortable, timestamped IDs like20260320_143000_6f00bfe3f7c54b2f86d780df58ccf0a1
Quick Start
[]
= "0.8"
= "0.8"
= { = "1", = ["full"] }
use ;
async
Architecture
A session is two files side by side: a .meta.json header and a .jsonl append-only log of agent messages. JsonlSessionStore writes each record with a monotonically-increasing sequence number so a crash mid-write leaves a recoverable state. FileCheckpointStore uses the same atomic-write pattern for whole-agent snapshots. SummarizingCompactor plugs into the core crate's ContextTransformer trait — it asks the current model to summarize old turns when the window gets tight, keeping the last N turns verbatim.
No unsafe code (#![forbid(unsafe_code)]). All writes are atomic (temp-file + rename); partial writes cannot corrupt a session.
Part of the swink-agent workspace — see the main README for workspace overview and setup.