A run may name another provider for itself (an agent’s
checkpoint_provider); see
What a per-run provider means.
The built-in stores
The
redis store needs a Redis with the JSON and search modules. Redis 8 ships both; a
Redis 7 needs RedisJSON and RediSearch loaded. On a plain Redis the store’s setup fails with
unknown command 'FT._LIST'. With LLM_PROVIDER_CHECKPOINT_CONN_STRING unset, the store uses the
base REDIS_URL, and when that is unset too the shared TAI_DEFAULT_REDIS_URL, so that Redis
is the one that must provide the modules. See
Infrastructure by feature for what every store needs.
Only a store that survives a restart (redis, postgres, or a registered store that declares it)
can hold a parked run (one waiting on an async ask): a paused run must be readable by
whichever worker later resumes it.
Retention: two horizons
A waiting thread is one its owner may still continue: a parked run, an open conversation,
any thread nobody marked finished. A finished thread is one its owner marked finished.
- On
redisevery key a write stores carries the waiting retention as its TTL. A read never extends it, so a thread lives the waiting retention after its last write. A parked run’s last write is its park checkpoint. - On a store the sweep keeps (
postgres,sqlite) the checkpoint sweep deletes a thread whose newest checkpoint is older than the waiting retention. - A finished thread goes the finished retention after its mark, on every provider, through the checkpoint sweep. The mark records the time the thread becomes due, from the retention in force at the mark: changing the finished value later moves only new marks.
INTERACTIONS_IDLE_TTL_SECONDS, default 1 day) after the ask’s deadline, so an async ask of
any run must carry a deadline at least that long before the checkpoint’s
waiting retention runs out (with the defaults, within 6 days): a park with no deadline, or one
past that point, is refused loudly before anything is parked. A resume that finds the thread’s
checkpoint gone ends the run as a failed terminal.
A thread’s own retention
The two values above are every thread’s default and its ceiling. A thread’s owner may declare a shorter retention for the threads it starts — a Babelfish flow, for example, declares one in its document (config.checkpoint_retention) — never a longer one:
- A declared value above the platform’s value for its horizon is refused loudly, naming both values; it is never shortened silently. A declared finished retention longer than the declared waiting one is refused too.
- A declaration may give only one value. An unset waiting is the platform’s; an unset finished is the platform’s finished retention, capped at the thread’s waiting one.
- On
redisthe declared waiting is the TTL of every key the thread’s writes store. Onpostgresandsqliteit is recorded when a run starts on the thread, and the checkpoint sweep reads it as that thread’s waiting horizon; a later run on the same thread replaces it. - A finished thread is due its declared finished retention after its mark.
- A park on such a thread must fit its declared waiting retention: an async
askwhose deadline runs past it is refused before anything is parked.
LLM_PROVIDER_CHECKPOINT_TTL_MINUTES is gone: its place is taken by the two retention values
above. The Babelfish flows engine’s FLOW_CHECKPOINT_RETENTION_DAYS and its
POST /api/babelfish/checkpoints/prune route are gone too: the same two values and the
platform’s sweep_checkpoints operation replace them. A deployment that still sets one of
the removed variables is refused at boot and on every settings write, naming it.Who marks a thread finished
The code that minted a thread id owns the thread and marks it finished at its end (a consumer may also take a caller-supplied id as its own); every consumer that starts a run on a thread takes it out of the finished set first, so a thread used again never sits there while it is live.- A consumer that owns the threads its runs start on marks them finished at the run’s terminal (success, error, stop or abort), never at a pause, and takes them out of the finished set when it starts a run on them again. A consumer that also owns threads whose runs may each choose a per-run provider marks those in the deployment’s ledger (the configured provider and connection). The Babelfish flows engine does both: a flow run always checkpoints on the deployment’s configured store, and the engine marks a run’s session thread (including a caller-supplied session id, which it takes as its own) and the agent session threads the run owns in the deployment’s ledger.
- An agent run with no
thread_idmints its thread and marks it finished when it ends without a park, in its own checkpoint provider’s ledger. A caller-suppliedthread_idis the caller’s: the run takes it out of the finished set when it starts and never marks it. A run that parks leaves its thread to the waiting horizon. - A conversation has no finished moment: a thread stays open for its next turn, so it
leaves on the waiting horizon, or at once when an operator deletes it
(
tai conversations delete-thread). A turn’s agent receives the conversation’s thread as a caller-suppliedthread_id: an agent that checkpoints on it takes it out of the finished set when its run starts (the agent-run rule above); an agent that keeps no checkpoints touches no checkpoint store.
The checkpoint sweep
sweep_checkpoints (POST /api/checkpoints/sweep, tai checkpoints sweep) is the one
operation that deletes checkpoint threads. It is admin-only and destructive; drive it on a
cadence with a schedule or external cron — nothing runs it in the background.
- Every thread marked finished whose due time has passed (its finished retention after the
mark) is deleted, on every provider,
memoryincluded. - On a store the sweep keeps (
postgres,sqlite), every thread whose newest checkpoint is older than its waiting retention (the one its owner declared, else the platform’s) is deleted. On a store kept by key TTL (redis) the TTL does this; on an in-process store (memory) the thread lives with the process — both reported inskipped.
tai42_checkpoint_sweep_spared_total{horizon,owner} (served on GET /metrics), listed in the
result, and — for a finished thread — kept in the finished set so the next sweep checks it
again. The filters the platform’s packages and the Babelfish flows engine
register claim:
A filter that fails fails the sweep. Deleting a thread removes every checkpoint and pending
write it holds, however many. A checkpoint a run writes while the thread is being deleted is
deleted again, up to 100 rounds, and then fails the sweep loudly. On the Redis provider one
delete already repeats until the thread is empty, and fails the sweep sooner: at the first
round, counting from its second, that leaves the thread holding no fewer checkpoints and writes
than the round before (
CheckpointDeleteError, naming the thread and what it still holds).
The result:
Scope: the deployment’s store
The sweep covers the configured provider and connection string only — the one store every process shares.What a per-run provider means
- A thread on a per-run
redisstore leaves on its key TTL (the waiting retention), marked or not. - A thread on a per-run
memorystore lives with its process. - A thread on a per-run
postgresorsqlitestore is not swept; its marks land in that store’s own ledger, so a deployment whose configured provider is that store sweeps them. - A thread marked finished in a ledger other than its own store’s (the Babelfish flows engine’s owned agent session threads, when the agent ran on a per-run provider) is not found by the sweep’s delete there, and leaves on its own store’s waiting horizon.
The store format
The kit records a format generation in each store the first time a saver is built on it (an in-process store starts empty with its process and needs none). A store that already holds checkpoints written in another format — or with no recorded generation — is refused at that first use withCheckpointStoreFormatError (“reset the checkpoint store before starting this version”): every
run, query or sweep that needs it fails loudly until the store is reset. A deployment that
uses no checkpoint store never builds a saver and never runs the check. The current generation
is 4: a store written by an earlier version is reset before this one starts on it. Drain in-flight
runs before the upgrade: the reset removes every open conversation’s memory, every parked run and
every other run thread the store held.
Large values are stored once
A run’s state often carries the same large value in many checkpoints: a document that stays the same while others change, or a result every later step keeps. Where storing once is on, a value whose encoding is larger thanLLM_PROVIDER_CHECKPOINT_SHARED_VALUE_BYTES is stored once per
thread, keyed by the SHA-256 of its encoding, and every checkpoint and pending write that
carries it holds a small reference in its place. The rule works on a value at any depth: a
dictionary of documents keeps each large document as its own stored value, so changing one
document stores only that one again. A value larger than LLM_PROVIDER_CHECKPOINT_INLINE_COMPRESS_BYTES
is stored compressed.
A store that copies channel values into every checkpoint stores large values once by default; one
that stores a channel once per version does not. So it is on for redis and sqlite by default:
their savers write every channel into every checkpoint, so a large value is otherwise copied into
each one. It is off for postgres and memory by default: their savers already store a channel
once per version, so storing sub-values once there saves bytes only inside a changing channel (on
postgres, in measured conversations the stored bytes fell to between about half and five sixths)
at a small cost on every save and read (about 2 ms per save in the same measurement). A deployment
turns it on or off for every store it opens with LLM_PROVIDER_CHECKPOINT_SHARED_VALUES.
- On
rediseach stored value is a keytai42:checkpoint:value:{<thread>}:<digest>, and a settai42:checkpoint:values:{<thread>}lists the thread’s values. Every write that references a value stamps it with the waiting retention, so a value lives as long as the newest checkpoint that references it. - On
postgresthe values are rows of the tabletai42_checkpoint_values, next to the saver’s own tables; onsqlitethey are rows of a table of the same name in the store’s file; onmemorythey live with the process, like its checkpoints. - A value leaves with its thread: deleting a thread — by the checkpoint sweep, by
tai conversations delete-thread, or by a consumer deleting its own thread (a Babelfish flow restart, for example) — deletes its values after its checkpoints, and onredisa thread nobody writes to again expires with its keys. - Reading a checkpoint fetches all its referenced values, the values nested inside them included, in
one extra round trip; every place that holds a value receives its own copy. A reference whose
value the store no longer holds fails the read with
CheckpointReferenceError, naming the thread and the value: that thread cannot be read; delete it. - On
postgresa value is written just before the checkpoint that references it. A process that stops between the two leaves that value’s row until its thread is deleted; for a thread whose first checkpoint never landed, the sweep never sees the thread, so the row stays until that thread id is deleted (tai conversations delete-thread). The library’s own blob rows have the same limit when a process stops in the middle of a thread’s delete. - The switch decides what a write stores. A checkpoint written while values were stored once reads back with its values whatever the switch says now; with the switch off a save and a read cost nothing beyond the saver’s own work.
Register a checkpoint store
A checkpoint store is a registration: a subclass ofCheckpointProvider
(tai42_kit.llm.checkpoint) that names the store, states three facts about it, and provides the
hooks the platform applies its features through. The four built-in stores are registrations of
the same kind; any saver written to LangGraph’s BaseCheckpointSaver contract can be one.
The name is the value of LLM_PROVIDER_CHECKPOINT (and of a run’s own checkpoint_provider):
lowercase letters, digits, _ and -, starting with a letter. The facts
(CheckpointProviderFacts) and what each makes the platform do:
What a registration provides:
open(conn_string): opens the store and returns its resource — the handle the saver is built on, the store’s finished-thread ledger and its per-thread value store — and the function that closes it. A store with no default connection raises naming the setting whenconn_stringis unset.saver(resource): the store’s saver, as its library builds it.value_encoding(saver, compress_threshold): how the store encodes a value for its value store and the resolver (MsgpackValueEncodingfits any saver that encodes values with its serializer’s msgpack form).recorded_generation,record_generation,holds_checkpoints: the store-format marker and whether the store holds checkpoints, for the format check.saver_with_waiting(resource, waiting_minutes), required whenretentionisnative_ttl: a saver and a value store whose writes carry that waiting as their key TTL.- Optionally
serializer(saver, compress_threshold), the serializer and codec the platform installs on the saver, andprepare_checkpoint/prepare_writes, a write preparation that knows the store’s own saver (the default followschannel_storage). The codec writes every value the saver stores, a value the platform encodes ahead of the saver included, and reads each one back.
tai42_kit.llm.checkpoint.stores).
To register a store, its module calls register_checkpoint_provider at import (or decorates the
class with it); a deployment lists that module under the manifest’s lifecycle_modules and sets
LLM_PROVIDER_CHECKPOINT to the store’s name:
native_ttl store without saver_with_waiting, or a class missing a hook is refused at import,
naming it. Registering the same class again (a module re-imported by a reload) changes nothing.
What the Redis store keeps
JSON has no form for most Python values a run’s state holds, so the Redis codec stores each such value in a typed envelope and reads it back as the same type:datetime, date, time,
timedelta, timezone (a datetime.timezone, or the fixed offset pydantic attaches to a value it
parses from text, bare or on a value), zoneinfo.ZoneInfo, Decimal, UUID, tuples, sets and frozensets,
dictionaries with non-string keys, bytes nested inside a value, enum members, pydantic models
and dataclasses (their classes importable by module path), the LangChain objects LangChain’s
own loader revives (its messages, documents and prompts) and LangGraph’s own types. A value of
any other type is refused at write, naming its path: so is a NaN or infinite float, which
JSON cannot hold, and a LangChain object its loader will not revive, such as a subclass of a
message class. A stored envelope that cannot be read back fails the read.
A datetime or time keeps its wall-clock value, its fold and its tzinfo when that is a
fixed offset (datetime.timezone, its name kept; the fixed offset pydantic attaches to a value
it parses from text is read back as a datetime.timezone with the same offset and name) or an
IANA zone (zoneinfo.ZoneInfo, kept by its key), so a value read back still follows its zone’s
daylight-saving rules. One carrying any other kind of tzinfo, or a zone read from a file
(which has no key), is refused at write, naming its path; a stored zone key the reading host’s
zone database lacks fails the read.
An exception is stored as a readable record and comes back as a CheckpointedException
carrying it:
kwargs holds the exception’s attributes; an attribute JSON cannot hold is stored as its
repr() and named in repr_kwargs, and an attribute holding another exception becomes its own record.
cause is the record of the exception it was raised from.
