Agent Reliability

AI Agent State Versioning: Migrations and In-Flight Runs

Version AI agent state across schemas, workflow changes, and paused runs with explicit compatibility checks, controlled migrations, and safe recovery plans.

· · 8 min read

Prepared with AI research assistance. Sources are linked throughout; worked examples are illustrative unless stated otherwise. Editorial approach.

An agent deployment can outlive the code that created it. A run may wait overnight for approval, resume after a tool outage, or read a checkpoint written several releases earlier. Updating the state type in the repository does not update those stored executions. State versioning is the contract that determines which software can interpret and safely continue each run.

This guide develops a hypothetical document-approval service. Its envelopes, migration policies, and rollout sequence are proposed engineering designs, not a tested framework implementation.

Version more than the serialized object

A checkpoint contains data, but its meaning also depends on execution logic. A saved next_node identifies code that must still exist. An evidence reference depends on the document version it describes. A pending approval refers to a particular action. Changing any of these relationships can break a run even when every JSON field still validates.

Separate at least these version dimensions:

Dimension Example change Compatibility question
State schema Split amount into value and currency Can the reader recover the original meaning?
Workflow definition Replace approve with two review stages Where does an interrupted run resume?
Tool contract Change accepted requests into completed results Will existing logic misinterpret progress?
Policy Require another reviewer above a threshold Does an earlier approval remain sufficient?
Prompt or model configuration Change evidence selection behavior Can the new behavior satisfy the run's acceptance contract?

Use separate identifiers because these changes have different migration and rollback rules. A single release number can identify a deployment bundle, but it should resolve to the component versions needed to investigate a run.

Understand the execution engine's compatibility rules

LangGraph documents different migration constraints for finished and interrupted threads. An interrupted thread must retain the node name it will enter on resumption; renaming a state key can discard its saved value, and incompatible type changes can break older state. These are framework mechanics, not a guarantee that a business-policy change is safe. LangGraph graph migrations.

Temporal has another constraint: workflow orchestration must remain deterministic against its recorded history. Its versioning guidance describes worker versioning and patching as ways to evolve running workflows. A data conversion that parses successfully does not automatically make a changed replay sequence valid. Temporal workflow versioning.

Before designing a migration, identify what the actual engine persists: snapshots, event histories, pending tasks, suspended node locations, or some combination. Ask whether an upgrade executes current code against old data, replays recorded commands, or routes the run to a compatible worker. Do not assume different engines share the same answer.

Give checkpoints an explicit envelope

For the illustrative service, use an envelope around domain state:

{
  "run_id": "review_example_42",
  "state_schema": "document-review/2",
  "workflow_definition": "review-flow/7",
  "revision": 18,
  "status": "WAITING_APPROVAL",
  "source_document": "doc_example@v4",
  "pending_action_id": "action_example_9",
  "payload": {
    "total_minor_units": 125000,
    "currency": "USD"
  }
}

These values are fictional. The envelope lets a dispatcher decide compatibility before passing the payload into a worker. Keep the schema identifier separate from the concurrency revision: schema 2 explains interpretation, while revision 18 identifies the latest accepted write.

A worker should declare which schema and workflow combinations it can read and which it may write. Reject an unsupported combination explicitly. Silently treating an unknown version as the newest version converts a visible compatibility problem into an invisible interpretation error.

Preserve immutable action identities and evidence references through conversion. A migration may rename a field, but it should not create a fresh identity for an action that could already have happened. The relationship to idempotency for agent actions is essential during recovery.

Distinguish structural compatibility from semantic compatibility

Schema compatibility is directional. Confluent's documentation distinguishes new readers accepting older records from older readers accepting newer records, and explains that transitive checks cover earlier versions rather than only the immediate predecessor. Its exact rules depend on serialization format and configuration. Schema evolution and compatibility.

Use that distinction when planning a checkpoint rollout. Test the new reader against every state version that can still resume, not just yesterday's version. An execution paused for a month can bypass several intermediate releases.

Structural acceptance remains insufficient. Suppose an old payload stores amount: 1250 without a currency. A new schema requiring integer minor units cannot infer whether this meant 1,250 dollars, 1,250 cents, or another currency. A default of USD may satisfy validation while inventing a financial fact.

In this proposed design, ambiguous records enter a migration-review queue. The converter can consult an authoritative document version if permitted, record the provenance of the recovered currency, and otherwise stop. Unknown values should stay unknown rather than become convenient defaults.

Choose between draining, routing, and migrating

Three strategies solve different problems:

  • Drain old runs: start new executions on the new version while compatible workers finish existing ones. This reduces conversion risk but can prolong operational support.
  • Route by version: retain more than one worker implementation and dispatch each checkpoint to a declared compatible version. This handles long-lived runs but increases deployment and security-maintenance obligations.
  • Migrate stored state: convert selected checkpoints and resume them under new code. This consolidates operations but requires explicit semantic mapping and recovery evidence.

A mixed strategy is often reasonable. Drain short runs, route pending approvals to older workers temporarily, and migrate only records whose conversion can be verified. Define a deadline and ownership for old-version retirement; otherwise temporary compatibility code can become permanent infrastructure.

The expand–migrate–contract pattern separates interface expansion, consumer migration, and removal of the old interface. Applying that sequence to checkpoint readers is an architectural adaptation here: first accept old and new representations, then migrate deliberately, then remove old support after proving it is no longer needed. Danilo Sato: Parallel Change.

Walk through a paused approval migration

Imagine the service originally stores one reviewer decision and a total in decimal currency units. The new workflow introduces integer minor units and requires two reviewers for larger requests. A run is paused before the original approval step when the release begins.

First inventory the checkpoint's schema, workflow location, document version, and pending action. Determine whether the run has produced any external effect. A pending status alone is not proof that an earlier request did not reach another service.

Next create a candidate converted record without overwriting the original. Convert the amount only when its currency and scale are established. Record the converter version, source revision, and validation results. Execute the converter twice against the same input and require the same output; this checks repeatability, not business correctness.

Then compare the old approval proposal with the new policy. If the required reviewers or action payload changed, invalidate the pending proposal and request a new decision. Do not reinterpret an old approval as authorization for a newly defined action.

Finally commit the converted checkpoint using a conditional update on its source revision. If another worker advanced the run meanwhile, discard the candidate and reread. Resume only after acquiring execution ownership under the application's normal concurrency rules.

This sequence should produce a migration event and a new checkpoint revision. It should not issue the business action as a side effect of data conversion. Execution and reconciliation remain separate, observable operations.

Make rollback a compatibility decision

Rolling back application code can be unsafe after new writers have emitted state that old readers cannot understand. Restoring an old checkpoint is also unsafe if a later external action already committed. Database state and the outside world do not roll back together.

Define rollback eligibility before deployment. During an expansion phase, new writers might retain a compatible representation so the previous reader can still operate. After an irreversible transformation, the recovery path may require a forward correction or version-specific worker instead of a binary rollback.

Keep an effect ledger separate from converted reasoning state. Before replaying an operation, reconcile its stable identity against authoritative results. If the migration exposed an already completed action, record that outcome rather than execute it again. Compensating transactions for agent workflows addresses cases where an actual business effect needs correction.

Validate the upgrade across historical states

Build a fixture inventory from sanitized representative checkpoints, including the oldest supported schema, pending approvals, parallel branches, partially completed actions, and explicit unknown outcomes. Validate both field interpretation and the permitted next transition.

Exercise these failure schedules:

  • A worker writes a newer revision while conversion is running.
  • A migration process crashes after writing its audit event but before committing state.
  • A run resumes at a node renamed by the new deployment.
  • A newer writer produces state immediately before an application rollback.
  • An old approval arrives after its proposal was superseded.

For each schedule, assert which checkpoint becomes authoritative, which worker may continue, and which external effects remain permitted. Track unsupported-version errors, migration-review backlog, and the count of resumable runs by version. Retire compatibility code only after the inventory shows no remaining consumers and the retention policy permits it.

Frequently asked questions

Is adding an optional field always safe?

No. A reader may accept the structure while downstream logic changes its interpretation. Check defaults, merge behavior, authorization decisions, and the actual engine's serialization rules.

Should every prompt edit require state migration?

Usually not. Record the prompt version for investigation and evaluation, then assess whether the change affects an in-flight run's contract. Migrate state only when its meaning or required execution conditions actually change.

Can the model migrate its own checkpoint?

A model can help propose a mapping for review. Deterministic converters, explicit evidence, validation, and execution controls should decide what is persisted. Ambiguous historical facts need resolution, not plausible completion.

Source reference list

AI Agents
State Versioning
Workflow Migrations
Agent Reliability