Skip to content

Thread listing

Status: decided, 2026-11-13 (ADR-0025 to ADR-0029); the index kept on 2026-11-14 on its measured cost (§4.1). Stage 6 was cut to feature 16, thread listing. Features 11, 12, 14 and 15 are dropped, each with a recipe on LangGraph's own API (§8). Feature 13 was deferred to a measurement; §8.3 has the outcome. The spike was first written as a proposal for a read-only companion class serving all six reads. Its research stays here as the evidence for each cut: the upstream facts in §1, the per-read analysis in §8 and the experiments in the appendix. Upstream here means langgraph-checkpoint-postgres 3.2.0, langgraph-checkpoint 4.3.1, langgraph 1.2.20 and langchain-core 1.8.0, on PostgreSQL 16.16. The three experiments (E1–E3) were run once; the appendix has each script and its output in full (measured below means "by that run"). None of them times anything: the dev host is IO-contended.

This reverses two earlier decisions, recorded as superseded: "convenience reads live in a read-only companion class, not on the saver" (2026-11-09) and ADR-0004 (paged messages kept). There is no companion class; listing is one function.

Answer in brief

  • One function, alist_threads(saver, *, filter=None, before=None, limit=None), in src/open_postgres_checkpointer/listing.py and exported from the package. It yields ThreadInfo(config, metadata, created_at) for each thread's latest root checkpoint.
  • Semantics: a thread is listed when its latest root checkpoint's metadata contains filter (@>, upstream's alist operator); newest first by that checkpoint's id, ties by thread_id; root namespace only. Returned configs carry no fence token.
  • Cost: one statement per page, metadata only: no value is read, so it needs no serde, no decode and no langgraph. From the saver it uses only the pooled connection and the migration-head check.
  • Index: the partial btree opc_checkpoints_root_latest ON checkpoints (checkpoint_id) WHERE checkpoint_ns = '', added only if benchmarks/list_index.py measures ours put p50 with it at most 1.05× ours without it on every arm, and every acceptance bar still holds. With it a page filtered to 1 % of threads read 243 buffers, against 80,245 for the best exact index-free query (E3, measured). If the bar fails there is no index, and listing ships as E3's Q1 over head rows, its cost and its headless-thread gap documented.

Superseded by ADR-0040 on 2026-11-30. The index is now (checkpoint_id DESC, thread_id DESC) WHERE checkpoint_ns = '' (migration 8), with a two-column keyset cursor. - Dropped: 11, 12, 14, 15. 11 and 12 cannot skip the DeltaChannel replay (U6), need the graph and would have to re-create aget_state's live overlay (U3); what they save, decoding the other channels, is unmeasured. 14 and 15 have no caller, and on a DeltaChannel graph 15's tuples hold no messages (U1). Deferred: 13, until aget_state_history is measured on a long DeltaChannel thread; built only if that measurement shows a cost.

1. What upstream does that the design depends on

U1–U7 are the evidence for the cuts (§8); U8–U12 shape listing.

# Fact Evidence
U1 A DeltaChannel stores no value at most checkpoints: its updates are the checkpoint's pending writes, and a full _DeltaSnapshot is stored when its update counter reaches snapshot_frequency (default 100) or its superstep counter reaches DELTA_MAX_SUPERSTEPS_SINCE_SNAPSHOT (default 5000). The counters ride in metadata.counters_since_delta_snapshot as [updates, supersteps] langgraph/channels/delta.py:50-64, 193-202; langgraph/pregel/_checkpoint.py:98-114; langgraph/_internal/_config.py:45. E2.1: with snapshot_frequency=3 a snapshot blob at two checkpoints of twelve, messages writes on the others
U2 aget_state rebuilds a DeltaChannel value by asking the saver for the channel's history (aget_delta_channel_history: the seed and the writes since) and replaying it through the channel's reducer, for exactly the channels with a version and nothing stored at the checkpoint pregel/_checkpoint.py:410-443 (_delta_channels_to_replay, _replay), 499-537 (achannels_from_checkpoint); E2.1: our saver's history replayed by the reducer equals aget_state
U3 aget_state on a config with no checkpoint_id is live: it applies the checkpoint's input writes (task id all zeros, from Command(update=…)), then the writes of every task that already finished in the step. With a checkpoint_id, and in aget_state_history, it applies the input writes only pregel/main.py:1422-1441, 1507 (live= is "no checkpoint id"), 1590 (history passes no live); pregel/_task_status.py:99-127. E2.3: stored ['go'], live ['go', 'from-model'], after Command(update) pinned ['go', 'via-command'], live ['go', 'via-command', 'from-model'], on the plain and the DeltaChannel graph alike
U4 add_messages replaces a message whose id is already in the list in place, removes by id, raises on removing an unknown id, and REMOVE_ALL_MESSAGES drops everything before it. A message removed in one step and re-added in a later one goes to the end; removed and re-added in one batch it keeps its place langgraph/graph/message.py:41, 199-247; E1.1–E1.4
U5 The DeltaChannel messages reducer, _messages_delta_reducer, is not add_messages: it ignores REMOVE_ALL_MESSAGES (treats it as a remove of an unknown id, silently) and ignores a remove of an unknown id instead of raising pregel/_messages.py:436-497, its docstring at 449 says so; E1.3: the list keeps all three messages and appends fresh; E1.4
U6 The newest page of a replayed message list is not determined by the newest writes: a write of an id the snapshot already holds replaces that message where it stands E1.5: newest two by replay 4:a2, 3:h2; by the newest writes 1:h1-edited, 4:a2
U7 A subgraph's state lives in its own namespace (child:<task id>). Root aget_state does not include it; aget_state(subgraphs=True) nests it under the pending task while the subgraph is interrupted; aget_state with that checkpoint_ns reads it, also after the subgraph finished pregel/main.py:886-897 (_subgraph_for_namespace finds the subgraph with get_subgraphs(namespace=…)), 1389-1420; E2.4
U8 BaseCheckpointSaver has nothing like a thread listing, a per-channel read or a multi-thread read. Its closest pieces: alist(config, filter=…) over checkpoints, and get_delta_channel_history for one channel's writes since its seed langgraph/checkpoint/base/__init__.py:250-720
U9 Upstream's metadata filter is JSON containment on the checkpoint row: metadata @> %s. Upstream indexes nothing that serves it; its only secondary indexes are on thread_id langgraph/checkpoint/postgres/base.py:837-879, 85-91
U10 Checkpoint metadata holds source, step, parents, the config's metadata keys and its configurable keys except internal ones and __-prefixed ones, so an application's tenant or user id lands on every checkpoint of a run that passed it base/__init__.py:807-836; E2.5: tenant from metadata, user_id from configurable
U11 A run's puts carry the configurable of the checkpoint it read, which overrides the caller's: a fence token the caller passed is replaced by the read's own, except when the read found nothing pregel/_loop.py:1883-1892; s5 U1
U12 "Latest" is the highest checkpoint_id in a namespace; checkpoint ids are client-side uuid6, and copy_thread keeps them s5 U8

2. Shape (decided)

@dataclass(frozen=True)
class ThreadInfo:
    config: RunnableConfig        # the thread's latest root checkpoint: thread_id, "", checkpoint_id
    metadata: CheckpointMetadata  # that checkpoint's metadata
    created_at: str               # that checkpoint's `ts`

async def alist_threads(
    saver: AsyncOpenPostgresCheckpointer,
    *,
    filter: dict[str, Any] | None = None,
    before: RunnableConfig | None = None,
    limit: int | None = None,
) -> AsyncIterator[ThreadInfo]: ...
  • A function, not a class. It has one read and no state of its own; a class would hold only the saver.
  • Parameters mirror alist's. filter is the point of the feature; before is a ThreadInfo.config from an earlier page, the keyset cursor; limit caps the total, and the function pages internally (_LIST_PAGE_SIZE rows a statement), as alist does.
  • What it takes from the saver: _fetch, which gives a pooled autocommit connection and runs the migration-head check once. Nothing else: the statement returns metadata (JSONB, which psycopg decodes, as _load_page takes it) and checkpoint ->> 'ts', so the serde, the patch decoder, the codec thread and the base cache are not touched. Write rule 6 (every read path resolves patches) does not apply: listing reads no stored value.
  • Where it lives: src/open_postgres_checkpointer/listing.py, its statement in _sql.py with the saver's, alist_threads and ThreadInfo exported from the package root. It imports only what the saver already imports; no langgraph dependency, because listing needs no graph.
  • No fence token in ThreadInfo.config: listing is not a run's read, and a token there could only act when the thread is gone, turning the application's next ainvoke into a ThreadConflictError (U11, s5 E2.5).
  • No transaction: one statement per page, so each page is one snapshot. Pages are not one snapshot together (§3.3).
  • Threads upstream wrote, and ours: the statement reads upstream's checkpoints table only, so a thread upstream wrote, one ours wrote and one adopted mid-way list alike. With the index it needs no head row; the fallback (§4) does.

3. Listing

3.1 Semantics

  • A thread is listed when it has a root checkpoint; its entry is its latest root checkpoint. Threads with only subgraph rows or only writes are not listed.
  • The filter matches when that checkpoint's metadata contains it (@>, upstream's operator, U9). This is the thread's metadata as aget_state(thread).metadata shows it, so the gate compares with it directly. Keys an application passes in metadata or configurable on every run are what it can filter on (U10).
  • Newest first by that checkpoint's id, ties by thread_id. This is what "latest" means upstream (U12). The head row's touched_at was the alternative: it is on the database clock, but only our root puts move it, setup() gives every adopted thread the same value, and upstream's writes never refresh it.

3.2 The statement (with the index, E3's Q3)

SELECT c.thread_id, c.checkpoint_id, c.metadata, c.checkpoint ->> 'ts' AS created_at
FROM checkpoints c
WHERE c.checkpoint_ns = '' AND c.metadata @> %(filter)s          -- filter only when given
  AND c.checkpoint_id <= %(after_id)s                              -- cursor only when given
  AND (c.checkpoint_id, c.thread_id) < (%(after_id)s, %(after_thread)s)
  AND NOT EXISTS (SELECT 1 FROM checkpoints n
                  WHERE n.thread_id = c.thread_id AND n.checkpoint_ns = ''
                    AND n.checkpoint_id > c.checkpoint_id)
ORDER BY c.checkpoint_id DESC, c.thread_id DESC
LIMIT %(limit)s

The index scan walks root checkpoints newest first; each candidate is kept only if it is its thread's newest, by one primary-key probe. The cursor is the AFTER fragment alist already uses, so the range scan stops at it.

3.3 Paging across a concurrent write or delete

Each page is its own statement. A thread written between two pages moves above the cursor: if it was not yet listed it is missed in this pass, and if it was listed it is not listed again. No page repeats an entry, because the cursor is strictly decreasing on (checkpoint_id, thread_id). The gate tests both cases.

A delete can move a thread below the cursor instead. Each page takes a thread's entry from whichever root checkpoint is its newest at that page's snapshot, so when a thread's newest root checkpoint is deleted after the thread was listed (adelete_for_runs, or a delete by other tooling), its next-older checkpoint becomes its entry, and a later page lists the thread again under it. The listing does not dedupe across pages, which would need state across statements; a caller that needs each thread once dedupes by thread_id.

3.4 What each candidate query reads

E3, measured: 20,001 threads, 507,000 checkpoint rows, one thread with 5,000 checkpoints newer than every other thread's; shared buffers touched by one call from EXPLAIN (ANALYZE, BUFFERS), not time.

Query Index No filter Filter matching 1 % of threads Filter matching the hot thread only
Q0 DISTINCT ON over every root checkpoint none 502,783 502,783 502,783
Q1 every head row, its thread's newest by a probe (exact order) none 80,245 80,245 80,245
Q1b head rows in head_id order, joined none / partial 9,621 / 369 9,611 / 421 9,611 / 12,820
Q2 distinct threads by a recursive skip, then a probe none 140,702 140,702 140,702
Q3 root checkpoints newest first, kept if newest none 23,905 8,864 23,848
Q3 partial 15,232 243 27,623

Reading it: without an index every exact query reads the whole table or one probe per thread per page, so its cost grows with the database, not the page. With the partial index, a page costs the root checkpoints newer than its last entry: 243 buffers for a 1 % filter, but 15,232 with no filter, all of it the hot thread's 5,000 newer checkpoints, each rejected by a probe (measured, E3). A filter that matches almost nothing scans the index to its end either way (27,623). Q1b is cheap only with the index; without it the planner hashed the whole table. Q1 and Q1b also miss threads with no head row, and Q1b orders by head_id, which is stale while upstream's savers still write.

3.5 The index

CREATE INDEX CONCURRENTLY IF NOT EXISTS opc_checkpoints_root_latest
    ON checkpoints (checkpoint_id) WHERE checkpoint_ns = ''

Superseded by ADR-0040 on 2026-11-30. The index is now (checkpoint_id DESC, thread_id DESC) WHERE checkpoint_ns = '' (migration 8), with a two-column keyset cursor.

In our migration ledger, with the opc_ prefix so an upstream index can never collide with it. Partial, so subgraph puts do not maintain it. On E3's data it is 15 MB beside a 23 MB primary key (measured). Alternatives:

Index Why not
None, Q1 over head rows 80,245 buffers a page at 20,000 threads, growing with threads (measured); misses headless threads. The fallback if the index fails its bar (§4)
None, Q3 sorting every call Reads the whole heap each page (23,905 buffers, measured)
An index on opc_thread_head.head_id Every root put would update an indexed column and stop being HOT (ADR-0024)
(checkpoint_id, thread_id) Larger, for an order the tie only needs on equal ids (a copied thread)
GIN on metadata Serves containment on any checkpoint, not the latest; the costliest index to maintain on every put

4. Write cost of the index, and how stage 6 measures it

Not run in this spike; it runs on an uncontended host from a clean commit, as s4 and s5's harnesses did.

  • Harness: benchmarks/list_index.py, modelled on s4_run_index.py (removed before publication), which measured the rejected run-id index: a root_index flag on _greenfield.Arm (beside the run_index flag that harness used, removed before publication), and the benchmark rule's arms each with and without it (upstream, upstream pipeline and ours on the plain graph; upstream and ours on the DeltaChannel graph), so the index is the only difference within a pair. Upstream's arms are measured too: after a rehydrate the index stays, and upstream's savers pay for it.
  • Workloads: sequential, one 400-step thread, interleaved arms, 3 repeats; concurrent, K = 8 and K = 32 threads on one saver. K = 32 is the case that matters: uuid6 ids are always the largest key, so every insert lands on the index's rightmost leaf page, and concurrent puts contend for it. A fan-out graph with 50 subgraph tasks per step confirms that subgraph puts do not touch the partial index.
  • Metrics: the benchmark rule's (put and get_tuple p50 and p95, client CPU, peak RSS, bytes per table and index after VACUUM, the index in index_bytes), plus the listing statement's buffers and p50 and p95 at 1,000, 20,000 and 100,000 threads, with and without a hot thread, against Q1.
  • Bar (ADR-0029): with the index, ours put p50 at most 1.05× ours without it on every arm, and every acceptance bar still met. ADR-0016's precedent is a 1.12× DeltaChannel put (measured before public release), which was rejected.
  • If it fails: the index is not added; listing ships as Q1 over head rows, its cost per page (one probe per thread) and its headless-thread gap documented on alist_threads, and the result recorded beside ADR-0016.

4.1 Result — measured, and the decision

Two runs of list_index.py, each on an uncontended dedicated host from a clean commit (4 CPU, 8 GB, PostgreSQL 16, pool of 8, 3 repeats; measured before public release). The harness's write-cost part is the same in both; each stopped in its listing pass at a larger thread count, the first on a harness bug (fixed before the second), the second when the container's 64 MB /dev/shm ran out at 100,000 threads (raised since). So 100,000 threads is not measured.

Ours put p50 with the index over without it:

Arm Run 1 Run 2
plain graph, sequential 0.950× 0.980×
DeltaChannel graph, sequential 1.127× 1.007×
plain graph, K=8 0.982× 0.993×
DeltaChannel graph, K=8 1.072× 0.982×
plain graph, K=32 0.971× 1.047×
DeltaChannel graph, K=32 1.016× 1.002×
fan-out to 50 subgraphs 1.012× 0.978×

Upstream's arms read the same way: within 1.05× everywhere except its sequential DeltaChannel arm in run 1 (1.071×). A DeltaChannel put takes about 1.1 ms, so the runs differ by up to about 0.15 ms, and two runs cannot tell that from noise. The fan-out arms put 60 root checkpoints and 3,000 subgraph checkpoints; the index held 60 entries, so subgraph puts never touch it. A 400-step thread's index took about 90 KB.

A 20-thread page, run 2:

Threads Page With the index (Q3) Head rows, no index (Q1)
1,000 no filter 0.88 ms 6.03 ms
20,000 no filter 0.71 ms 156.6 ms
20,000 1 % of threads 1.18 ms 140.6 ms
20,000 no filter, behind a thread of 5,000 newer checkpoints 117.1 ms 151.4 ms
20,000 only that thread matches 271.6 ms 149.3 ms

Q1 reads all 80,241 buffers of the head rows on every page, so it grows with the thread count; Q3 reads the root checkpoints newer than the page's last entry.

Note (2026-11-17): what the two runs' figures mix. The figures above stay as measured; the harness that took them differed from today's list_index.py in three ways. (1) A listing cell's buffers came from one EXPLAIN with literal values, a custom plan, while its timed calls ran as statements psycopg had prepared, which Postgres can switch to a generic plan; a pooled saver connection prepares every statement and runs the generic plan. Where the two plans differ, a cell's buffers and its times describe different plans: at 2,000 threads and a 500-checkpoint hot thread, the 1 % and hot-only filters read 2,078 and 2,082 buffers on the custom plan and 2,465 and 2,469 on the generic plan (measured, 2026-11-17, PostgreSQL 16, tests/integration/test_bench_scenarios.py sizes). Which plan a timed call ran depended on the order of the cells. (2) The no-filter Q3 cells sent metadata @> '{}', which alist_threads never sends. (3) The concurrent ratios above (K=8, K=32) are of the p50 of every repetition's puts pooled, not the median of the per-repetition p50s that four_arm.py and s4_run_index.py (removed before publication) judge their bars on. The harness now times and explains every cell on its generic plan with the statement alist_threads sends, and judges the concurrent bar on the median of the repetitions.

Decision (2026-11-14): keep the index. Run 1 puts the DeltaChannel arms over ADR-0029's 1.05× bar and run 2 puts them under it. A cost of at most about 0.15 ms on a DeltaChannel put was judged worth a listing page 50–200× faster at 20,000 threads, and further repeats were dropped.

What the cost should be (inferred from the shape): one btree insert of a 36-byte key per root put, on the rightmost leaf; nothing for subgraph puts or put_writes. On the DeltaChannel graph a put stores no value, so the insert is a larger share of it, as it was for the run-id index; that index covered every namespace, this one only the root.

5. The premortem, item by item

Assume stage 6 shipped and failed. Items that applied only to the dropped reads (snapshot races between statements, base-cache priming, the shared codec thread, upstream's private rebuild function, memory of large values) went with them.

# Item Disposition
1 Most likely cause: an application filters on a key it passed only on a thread's first run; later checkpoints lack it and the thread drops out of the listing (U10). It expected Platform-style thread metadata Documented on alist_threads and in the stage 8 adoption guide: pass the key on every run. Containment on any checkpoint was rejected (ADR-0028)
2 The constraint nobody confirmed: that the index fits the bar on the DeltaChannel arm, where a put stores no value and the run-id index measured 1.12× (measured) §4 measures before the index is a default; the fallback is decided ahead (ADR-0029)
3 The question worth asking: if the index fails, at what thread count does the fallback's one probe per thread per page become too slow? §4 measures Q1 at 1,000, 20,000 and 100,000 threads, so the fallback ships with its numbers
4 A token in a returned config refuses the application's next ainvoke on a thread deleted and re-created since the listing (U11) No token in ThreadInfo.config (ADR-0027)
5 The index: rightmost-leaf contention at K = 32; CREATE INDEX CONCURRENTLY on a large adopted table makes setup() slow and, if interrupted, leaves an invalid index that IF NOT EXISTS then skips; rehydrate leaves it on upstream's table §4 measures K = 32. The migration drops an invalid index of that name before creating it. The rollback guide's manual drop step lists the index with our tables
6 A thread with many recent checkpoints makes an unfiltered page read each of them (15,232 buffers for 5,000, measured) Accepted: it costs that thread's newer checkpoints once a page, not the database; documented
7 copy_thread keeps checkpoint ids, so a copy lists beside its source, not at the top; keyset paging misses a thread that gets a new checkpoint while the caller pages (§3.3) Ties order by thread_id, so paging stays stable; both documented on alist_threads
8 Adjacent consumers: a new migration runs at every saver's setup() Our ledger only; upstream's migrations and head check are untouched, and the conformance suite runs unchanged

6. Stage 6 gate, made concrete

"Listing is compared with the same answer obtained through the graph's own get_state": tests/integration/test_listing.py, a seeded fuzz (this project does not depend on Hypothesis; tests/integration/test_lifecycle_property.py) over a fleet whose threads vary in metadata, written:

  • by upstream's AsyncPostgresSaver, by ours with patches, by ours in full-copies mode, and adopted mid-thread (upstream's turns, then ours);
  • on the plain add_messages graph and the DeltaChannel(_messages_delta_reducer) graph;
  • with subgraph namespaces present (a subgraph graph), which must never be listed or change a thread's order.

The oracle is built in Python from aget_state(thread) for every thread: its metadata, a containment function for flat keys (independent of the SQL, wiki guard-tests-must-be-able-to-fail), and its config's checkpoint_id for the order. Each listing, for random filters and every page size, equals the oracle, and each ThreadInfo.config carries no token. Pagination with before across a concurrent write: a thread written between two pages is never listed twice and no entry is repeated (§3.3). A thread with no root checkpoint is absent. Each guard mutation-checked.

"Thread listing's index has a recorded write cost": §4's run in the ledger, judged against ADR-0029's bar; on a failure, the fallback's listing cost recorded instead.

7. Decisions (decided 2026-11-13)

Spike decision Outcome ADR
Scope Stage 6 is feature 16 only. 11, 12, 14 and 15 are dropped, each with a recipe on LangGraph's API (§8); this supersedes ADR-0004 and the 2026-11-09 companion decision ADR-0025
D5, feature 13 Deferred until aget_state_history is measured on a long DeltaChannel thread; built only if that measurement shows a cost ADR-0026
D1, D3, D10, D12, shape A module-level function taking the saver, alist_threads(saver, *, filter, before, limit), yielding ThreadInfo(config, metadata, created_at); no reader class, no graph, no langgraph dependency; no fence token in returned configs ADR-0027
D8 (a): containment on the latest root checkpoint's metadata; newest first by its checkpoint_id, ties by thread_id; root namespace only ADR-0028
D9 (a), with the bar set (a target, so claimed): the partial index only if ours put p50 with it is at most 1.05× without it on every arm and every acceptance bar still holds; otherwise no index, Q1 over head rows, its cost and headless-thread gap documented ADR-0029
D11 Moot: listing is one statement per page —
D2, D4, D6, D7 Moot: their reads were dropped —

8. The dropped and deferred reads: why, and the recipe instead

This is the spike's analysis of features 11–15 as proposed. It is kept as the evidence for each cut.

8.1 Feature 11 — latest value of named channels (dropped)

Analysis. A read restricted to named channels would have loaded only their stored values and pending writes in one statement, then rebuilt each value through the graph's channel spec: DeltaChannel replay (U2) and, to agree with aget_state, the live overlay of input writes and finished tasks' writes (U3). Both need the reducer, so the read needed the compiled graph and a langgraph dependency, and it would have re-created aget_state's overlay rule outside it, without its check that a task is among the step's next tasks (which needs every channel). Its saving: decoding the other channels' values and skipping task preparation, never measured. The replay of the named channel is the same work.

Recipe.

state = await graph.aget_state({"configurable": {"thread_id": thread_id}})
latest = {k: state.values[k] for k in ("messages", "summary") if k in state.values}

8.2 Feature 12 — messages, newest first, paged (dropped)

Analysis. A page cannot be right without the full list: a write that looks like an append can replace a message from the snapshot where it stands (U6, E1.5), and a removal then re-add moves a message (U4). So a page needs the list rebuilt from the last snapshot, exactly as aget_state builds it (E2.1: a snapshot of 6 messages plus 2 writes, measured), and the design reduced to feature 11 plus a slice. The two standard reducers also disagree (U5), so a hard-coded reducer would be wrong for one graph type.

Recipe.

messages = (await graph.aget_state(config)).values.get("messages", [])
page = messages[-limit:][::-1]  # newest first; the next page slices before the last one shown

8.3 Feature 13 — history of one channel (to build, an open follow-up)

Analysis. The proposal: the committed value at each checkpoint of the parent chain where the channel's version changed, newest first, by a recursive walk along parent_checkpoint_id that fetches each distinct version once; for a DeltaChannel, one history walk to the seed and a forward replay emitting each version's value. Against aget_state_history, which re-replays each DeltaChannel from its snapshot once per checkpoint, the saving grows with the thread. Whether that is a real cost on a long DeltaChannel thread is what benchmark 3 measured: 26–27 minutes at 5,000 steps on both savers (core-set-results.md, benchmark 3), so it is to be built (ADR-0034). Until then: graph.aget_state_history(config) and compare consecutive values.

8.4 Feature 14 — channels changed between two checkpoints (dropped)

Analysis. A comparison of the two checkpoints' channel_versions, loading no value. For a DeltaChannel the version moves on every update (U1), so "changed" means "updated", not "value differs". No caller asked for it.

Recipe.

a, b = await saver.aget_tuple(config_a), await saver.aget_tuple(config_b)
va, vb = a.checkpoint["channel_versions"], b.checkpoint["channel_versions"]
changed = {k for k in va.keys() | vb.keys() if va.get(k) != vb.get(k)}

8.5 Feature 15 — latest checkpoint of many threads (dropped)

Analysis. One select_sql statement would have returned the tuples aget_tuple returns, saving one round trip per thread. No caller asked for it; a thread-list page that needs ids and metadata uses listing; and on a DeltaChannel graph the tuples hold no message list (U1).

Recipe.

tuples = await asyncio.gather(*(
    saver.aget_tuple({"configurable": {"thread_id": t, "checkpoint_ns": ""}}) for t in thread_ids
))

The calls run at most the pool's size at a time, and on a saver that writes, each aget_tuple holds the latest values' bases in its cache, as a run's read does (inferred from aget_tuple's priming, aio.py aget_tuple); a saver built with full_copies_only=True skips that.