Skip to main content
The pinned source provides two independent storage abstractions:
  • BaseStateRepository stores state by caller-supplied ID.
  • BaseSnapshotStore records chronological state copies attributed to a mutator ID.
Neither is automatically owned or invoked by the abstract LangState orchestrator.

In-memory repository

The in-memory repository stores the state object itself, not a copy. Mutating a retrieved object therefore mutates the stored object. Use it for tests or process-local sessions, not durable or distributed persistence. get_or_create(state_id, factory) is supplied by the base repository. clear() is a synchronous convenience on the in-memory implementation.

Bounded snapshots

record_snapshot() calls state.copy() before storing an immutable Snapshot dataclass. The default capacity is 100; when capacity is exceeded, the oldest stored snapshot is discarded. Snapshot indexes count total recordings and are not renumbered after eviction.

Production integrations

Database, cache, synchronization, serialization, tenancy, and retention policies are application responsibilities. Implement the base interfaces and test copy/identity semantics explicitly for your backend.