By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
A graph's state schema used to change with the code. With a checkpointer it does not: checkpoints written by last month's graph are still in the store, and some of them are paused threads waiting for a human. Those checkpoints carry channel values for the schema that existed when they were written. Deploying code that assumes new fields is therefore not only a code change — it is a data migration with a deploy in the middle of it.
There are two entry points into old state, and they behave differently. A new run starts at START, so a migration node at the front of the graph sees the state you pass it. A paused thread resumes at its pending node, not at START: the runtime restores the checkpoint and continues from the task that was interrupted. A migrate-at-START node will not save you there. Migration has to happen before the resume, or inside readers that tolerate the old shape.
The cheapest compatible change is addition. An optional field that old checkpoints do not have can be read with .get(name, default) by every node that needs it. Old checkpoints stay readable, old code ignores the new field, and rollback is usually safe because the extra key is harmless. Renaming, removing or repurposing a field is a different kind of change: the old value is still in the checkpoint, but the new code looks somewhere else.
| Change | Old checkpoints | What to do |
|---|---|---|
| Add an optional field | No value; every reader must default | Deploy tolerant readers first, then the writer; bump schema_version and test with a recorded snapshot |
| Add a channel with a reducer | Missing from old checkpoints; reducer has no history | Treat as a version bump and verify against an old fixture before relying on the default |
| Rename a field | Old value is invisible under the new name | Dual-read and dual-write across two releases, then drop the old key |
| Change a field's type | Old values may not coerce or validate | Version the state and convert values in a migration before any new node reads them |
| Change a channel's reducer | Old merged values mean something different; replay merges differently | Treat as a data migration, not a code change; do not do it while threads are paused on the old channel |
| Remove a field | Readers fail or silently default | Remove only after every thread is migrated or archived, and keep one release of tolerance first |
The practical rules for additive fields are small. Always give a default in one shared helper rather than scattering .get calls. Never reuse a field name for a new meaning — that is worse than renaming because it corrupts silently. And treat the reducer on a channel as part of the schema: changing how values merge changes the meaning of every old checkpoint and every replay.
Give the state a version channel so the code can tell what it is reading. A schema_version: int field, a constant in the module (STATE_SCHEMA_VERSION = 2), and a pure function per upgrade step is enough: migrate_v1_to_v2(state) returns a new dict and never mutates its input. Keep every old function forever — checkpoints do not disappear when a new release ships — and make each one idempotent so it is safe to run twice.
Run migrations in three places. A migrate node at START upgrades new runs before any work happens. A migration call before resuming a paused thread upgrades the checkpoint it is about to continue. A backfill script upgrades stored snapshots you want ready in advance. Replays are a fourth case with the same rule: a replay resumes mid-graph from the checkpoint, so fork it and migrate the fork before replaying. One function, several callers, one test suite. The version is also what lets the caller refuse to resume: if a thread's version is newer than the deployed code understands, stop and deploy forward rather than guessing at fields.
from typing import Any
STATE_SCHEMA_VERSION = 2
def migrate_v1_to_v2(state: dict[str, Any]) -> dict[str, Any]:
"""Upgrade one checkpoint's channel values. Pure and repeatable."""
if state.get("schema_version", 1) >= STATE_SCHEMA_VERSION:
return dict(state)
upgraded = dict(state)
upgraded["schema_version"] = STATE_SCHEMA_VERSION
upgraded.setdefault("retry_budget", 3)
upgraded.setdefault("handoff_log", [])
# The old ambiguous `next` string becomes an explicit handoff field.
if "next" in upgraded and "next_agent" not in upgraded:
upgraded["next_agent"] = upgraded.pop("next")
return upgraded
v1_checkpoint = {
"schema_version": 1,
"messages": [],
"findings": ["refund within 30 days"],
"next": "billing",
}
migrated = migrate_v1_to_v2(v1_checkpoint)
print(migrated["schema_version"])
print(migrated["next_agent"])
print(migrated["retry_budget"])
print("next" in migrated)
print(migrate_v1_to_v2(migrated) == migrated)graph.get_state(config) returns the pending snapshot: the channel values, which nodes are next, and the tasks the checkpoint holds. Read the version before deciding what to do, and read next before deploying, because the paused thread's pending task names the node it will resume into. If that node was renamed or deleted, the thread cannot resume — the checkpoint points at a node the current graph no longer has. Keep the old node as a thin alias that routes into the new graph for one release, or drain the paused queue before deploying.
from langgraph.types import Command
from support_graph import build_graph # the factory from the deployment lesson
STATE_SCHEMA_VERSION = 2
graph = build_graph()
config = {"configurable": {"thread_id": "thread-c91"}}
snapshot = graph.get_state(config)
if snapshot.values.get("schema_version", 1) < STATE_SCHEMA_VERSION:
graph.update_state(
config,
{"schema_version": STATE_SCHEMA_VERSION, "next_agent": "billing"},
)
# The pending task now resumes with migrated state and the current node code.
result = graph.invoke(Command(resume="approved"), config)Checkpoints are data in the saver's format. The runtime deserialises state values when it reads them, so anything exotic you stored — a custom class, a dataclass that gained a required field, a renamed enum — becomes a compatibility problem when the old bytes are read by new code. Prefer JSON-like primitives and ids in state, and keep rich objects derivable from them. If a custom type is unavoidable, its module path and fields are part of your schema, with the same migration discipline.
The honest test is a fixture: record a real snapshot from the previous release, commit it as JSON, and in CI migrate it and assert the result is what the new schema promises. A fixture that fails is a release note. The same failure in production is an incident with a paused customer on the other side of it.
schema_version and export representative snapshots as fixtures before changing anything.Checkpoint history makes a thread rewindable: get_state_history lists the snapshots for a thread, each with its own config, and you can replay from one or fork it with update_state. That is a debugging superpower, not an undo button. Replaying re-runs every node after the chosen checkpoint, and external effects are not undone — a refund already issued, an email already sent. Any non-idempotent write in the replayed range will happen again.
Rewinding across a schema change adds two rules: migrate the state at the fork point before replaying, and replay against sandboxed copies of external services when nodes write. Keep the production thread untouched so the audit trail stays real; fork to a scratch thread id and let the original remain the record of what actually happened.
Key takeaways
Checkpoints outlive deploys: paused threads written by an older schema will be read and resumed by newer code, so schema changes are data migrations.
A paused thread resumes at its pending node, not at START, so a migrate-at-START node does not protect it; migrate before the resume or make readers tolerant.
Additive optional fields with defaults are safe; renames, type changes, reducer changes and removals are migrations that need versioning and tests.
Version the state with schema_version and pure, idempotent migration functions; keep every old function, because old checkpoints do not disappear.
Rewinding replays nodes and does not undo external effects: fork the thread, migrate the fork, replay against sandboxes, and keep the original as evidence.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.