AI

AgentOps: validate checkpoint recovery before resuming a production workflow

A production runbook for reconciling agent checkpoints, tool side effects, approvals and idempotency before resuming an interrupted workflow or rolling it back.

10 Nov 2026 aiagentopsagentsmcpmicrosoft-foundryautomationcheckpointidempotencyobservabilitykqlevaluationguardrailsrunbookrollbackproduction

An operations agent prepares a production change, obtains human approval and calls a bounded automation tool. The runtime restarts before the tool response is persisted. On recovery, the checkpoint still says execute_change: pending, so the orchestrator calls the tool again. The first call had already reached the backend. One interruption has now become two production operations.

This failure is easy to misread as a retry problem. It is a state-reconciliation problem across the agent runtime, checkpoint store, MCP or tool gateway, queue and target system. A durable checkpoint can preserve the conversation and workflow position without proving what happened outside the runtime.

The running case is an internal agent that prepares and executes a controlled configuration change. The same runbook applies to a ticket creation, deployment, restart, secret rotation or rollback request. The outcome is explicit: resume from a proven step, compensate a partial effect, restart from a safe boundary or keep writes blocked.

Define the checkpoint recovery contract

A useful checkpoint records more than the next node in a graph. It binds the saved state to the versions and decisions that made the next action valid.

yaml 01-checkpoint-recovery-contract.yml
checkpoint:
workflow_id: change-7842
checkpoint_id: cp-7842-06
sequence: 6
created_at: 2026-11-10T07:42:18Z
agent_release: ops-agent-2026.11.10.1
workflow_definition: change-flow-v12
tool_catalog: ops-tools-v47
policy_version: prod-actions-v21

action:
tool: execute_approved_change
target: app-prod-eu
normalized_arguments_hash: sha256:example-action-hash
approval_id: approval-9914
approval_expires_at: 2026-11-10T08:00:00Z
idempotency_key: change-7842-execute-v1

saved_state:
phase: execution_requested
dispatch_status: unknown
backend_operation_id: null

resume_requires:
- checkpoint_integrity_valid
- versions_still_authorized
- approval_still_bound_and_valid
- external_effect_reconciled
- next_step_compare_and_set

Treat the checkpoint as an immutable observation, not current truth. On recovery, re-read policy, approval, target state and backend operations. If the workflow definition or tool schema changed, migrate the checkpoint explicitly or restart from an earlier safe boundary. Do not silently interpret old state with new code.

Freeze the interruption before resuming

Disable automatic resume for the affected workflow class and preserve the last healthy checkpoint, the recovered checkpoint, queue messages, tool-call traces and backend audit records. Record one UTC window around the interruption and identify every component that can retry independently.

text 02-recovery-evidence.txt
Freeze
workflow ID, checkpoint ID and sequence
runtime instance and restart reason
agent, workflow, tool catalog and policy versions
approval ID, scope and expiry
tool call ID and idempotency key
queue message ID, delivery count and lease state
backend operation ID when known
target state before and after interruption

Do not yet
advance the checkpoint
replay the queue message
renew the approval
generate a new idempotency key
infer failure from a missing tool response

A missing response proves only that the runtime did not persist a result. The gateway may have accepted the call, a worker may hold the message, or the backend may have committed the change. Recovery starts by finding that boundary.

Classify the last side-effecting step

Map the interrupted action to one state before choosing a resume point:

  • not_dispatched: no call left the runtime;
  • denied: policy or approval rejected it before backend acceptance;
  • queued: a message exists but no worker or backend accepted it;
  • accepted: the backend has an operation identifier but no terminal result;
  • completed: the intended effect is visible and attributable to this workflow;
  • partial: only part of the requested effect is present;
  • failed_without_effect: terminal failure and the target is unchanged;
  • unknown: evidence cannot distinguish two or more states.

Only not_dispatched, denied and a proven failed_without_effect can usually return to the execution boundary. Accepted needs observation or cancellation, completed advances past execution, and partial follows the backend compensation contract. Unknown blocks automatic writes.

Do not classify from the checkpoint alone. Correlate workflow, call, queue and backend identifiers, then verify the target directly. A completed operation with missing telemetry is still completed; a successful tool response with an unchanged target may still be incomplete.

Make idempotency survive the runtime

An idempotency key helps only when every path preserves it and the system that owns the effect enforces it. The key must be created before dispatch, stored in the checkpoint, propagated through the tool gateway and queue, and recorded by the backend with a durable result.

yaml 03-idempotency-and-resume-gates.yml
request:
workflow_id: change-7842
action_id: execute-v1
idempotency_key: change-7842-execute-v1
action_hash: sha256:example-action-hash

backend_rules:
first_key_use: create_operation_and_store_result
same_key_same_hash: return_existing_operation
same_key_different_hash: reject_conflict
result_retention: longer_than_maximum_resume_window

checkpoint_transition:
expected_sequence: 6
next_sequence: 7
condition: external_effect_reconciled
duplicate_writer: reject_compare_and_set

Do not generate a fresh key after a timeout: that turns an ambiguous first attempt into an authorized duplicate. Also guard checkpoint writes with a sequence or compare-and-set condition. Two recovering runtime instances must not both advance the workflow.

Some operations cannot be made naturally idempotent. Split them into prepare, execute and read_status capabilities. Persist a reviewable artifact or backend operation ID before the irreversible step, and require a new approval when the target, arguments, contract version or expiry changes.

Reconcile traces and target state

Use a bounded query to reconstruct the action path. The following KQL assumes normalized events; map the table and fields to the actual telemetry pipeline.

kusto 04-reconcile-checkpoint-resume.kql
let TargetWorkflowId = "change-7842";
let Start = datetime(2026-11-10T07:35:00Z);
let End = datetime(2026-11-10T08:10:00Z);
AgentActionEvents
| where TimeGenerated between (Start .. End)
| where WorkflowId == TargetWorkflowId
| project TimeGenerated,
        Component,
        EventType,
        CheckpointId,
        CheckpointSequence,
        ToolCallId,
        QueueMessageId,
        BackendOperationId,
        IdempotencyKey,
        ActionHash,
        ApprovalId,
        Result
| order by TimeGenerated asc
| summarize
  Components=make_set(Component, 10),
  Events=make_list(EventType, 50),
  Results=make_set(Result, 10),
  Operations=make_set(BackendOperationId, 10),
  FirstSeen=min(TimeGenerated),
  LastSeen=max(TimeGenerated)
by WorkflowId, IdempotencyKey, ActionHash, ApprovalId

Read the result alongside the backend audit log and current target state. Check for the same idempotency key with different hashes, the same hash under several keys, two backend operations, a consumed approval reused after recovery, or a checkpoint sequence written by multiple runtimes.

When observability is incomplete, prefer a read-only reconciliation adapter over another execution attempt. It should query by idempotency key, external operation ID and target state without requiring the agent to reinterpret free-form logs.

Revalidate policy and approval

Recovery may happen minutes or hours later. Re-evaluate the authorization context rather than trusting the serialized decision. Confirm that the approver is still valid, the approval has not expired or been consumed, the action hash is unchanged, the target still matches, the policy version is authorized and the execution identity retains only the required capability.

If any field affecting the action changes, prepare a new artifact and request a new approval. Do not edit the checkpoint to make the old approval appear compatible. Keep the old checkpoint and decision as evidence, then create a new workflow branch with its own action and idempotency identifiers.

Re-reading policy does not mean letting the model decide whether an approval is close enough. Enforce the binding in deterministic code at the tool or backend boundary.

Exercise recovery with controlled failures

Test recovery before enabling it for production writes. Inject interruptions at several boundaries and verify both the resumed result and the absence of duplicates.

yaml 05-checkpoint-recovery-evaluation.yml
cases:
- id: crash_before_dispatch
  interrupt: after_checkpoint_before_tool_call
  expected: one_call_after_resume

- id: crash_after_gateway_accept
  interrupt: before_runtime_persists_response
  expected: existing_operation_reconciled_no_second_effect

- id: duplicate_runtime_recovery
  interrupt: two_instances_load_same_checkpoint
  expected: one_checkpoint_writer_one_backend_operation

- id: approval_expires_during_pause
  interrupt: wait_beyond_expiry
  expected: resume_blocked_new_approval_required

- id: tool_contract_changes
  interrupt: deploy_new_schema_before_resume
  expected: explicit_migration_or_safe_boundary_restart

- id: partial_backend_effect
  interrupt: fail_second_backend_step
  expected: compensation_path_no_automatic_replay

gates:
duplicate_backend_operations: 0
reused_consumed_approvals: 0
unknown_external_effects: 0
concurrent_checkpoint_advances: 0

Use a disposable target first, then a no-impact production canary. The canary must include a real runtime restart and a delayed or lost response; a unit test that reloads serialized state does not exercise the external ambiguity.

Decide resume, compensate or roll back

Resume at the next step only when the external effect is reconciled, the checkpoint integrity and sequence are valid, versions remain compatible, policy still allows the action and approval is still bound to the exact action. Resume at the execution boundary only when non-dispatch or failure without effect is proven.

Compensate when a partial effect exists and the backend has a tested recovery operation. Keep the agent workflow paused while compensation runs through a separately approved path, then record the resulting safe state before closing or branching the workflow.

Restart from an earlier safe boundary when the tool contract, workflow definition or target has changed. This is not a replay: create a new action artifact, approval and idempotency key while retaining the abandoned branch for audit.

Keep writes blocked when the effect is unknown, the backend cannot query idempotency, multiple runtimes can advance the same checkpoint, or recovery depends on interpreting an expired approval. Roll back automatic recovery to read-only mode and require manual reconciliation until those controls are fixed.

Conclusion

A durable checkpoint preserves agent state; it does not make external side effects durable, atomic or safe to replay. Production recovery therefore needs a contract that joins checkpoint sequence, workflow and tool versions, approval binding, idempotency and backend evidence.

The decision is operational: resume only from a proven boundary, compensate known partial effects, start a new branch when the contract changed, and leave writes disabled while any external effect remains unknown. That is what turns checkpointing from a convenience into an exploitable recovery mechanism.