Skip to content

agentix.store

store

Run persistence — a pluggable key/value store for checkpointed run state.

agentix doesn't assume a database. Store is a two-method protocol; core ships MemoryStore (a dict, the default) and FileStore (one JSON file per run). Bring your own Redis/Postgres/S3 backend by implementing the same two methods.

The persisted state is a plain JSON-able dict (see :mod:agentix.serde): {"run_id", "steps", "tokens_used", "messages": [...]}.

MemoryStore

MemoryStore()

In-process store backed by a dict. Default; ideal for tests.

FileStore

FileStore(path: str | Path)

One JSON file per run under path (created on first save).

Writes are atomic (temp file + fsync + os.replace) so a crash mid-write can't corrupt or truncate a checkpoint — a reader always sees the previous complete file or the new complete file, never a partial one. File I/O is offloaded to a worker thread so it doesn't block the event loop.

Concurrency: safe for concurrent readers/writers in the sense that no reader ever sees a torn file. Two writers racing on the same run_id resolve last-writer-wins (no corruption) — but you should still keep a single writer per run, especially across processes (there is no cross-process lock).