Back to catalog / Agent recovery
Resume an interrupted agent task from saved run state
Save resumable run state so the same agent workflow can continue after interruption.
Goal
Resume after interruption instead of treating a partial result as a completed answer.
Steps
- Distinguish a final answer, a pending tool call, and resumable intermediate run state. [openai-results] [openai-running]
- Save
state=result.to_state()after the run; persist it withstate.to_json()/RunState.from_json(...)if needed. [openai-results] [openai-running] - Resume with the original session backend and session ID:
await Runner.run(agent, state, session=session); give that history exclusive access. [openai-results] [openai-running] - Fail explicitly for expired or incompatible state and provide a safe-checkpoint restart path. [openai-results] [openai-running]
- Simulate interruption and resume; confirm completed side effects are not repeated unconditionally. [openai-results] [openai-running]
How to verify
Save and resume a non-terminal RunState; with an exact original session-history match, the SDK reconciles completed tool results without rerunning tools.
Troubleshooting
If saved state is incompatible, fail closed and restart from a verified checkpoint rather than replaying every tool.
Permissions
Prerequisites
- Python 3.10+, openai-agents compatible with the pinned revision, and authorized model-provider credentials (except local mock tests)
Permissions
- Use a local or isolated test environment; use least privilege and approval for external data or side effects
Limitations
Recovery fails closed if concurrent writes alter the original session history or its tail mismatches. A state whose accepted final output/terminal hooks failed to persist is unrecoverable; start a new run.
Pinned upstream source
- Repository
- openai/openai-agents-python
- File path
- docs/results.md
- Pinned commit
f53c62451c7f34c15f0c87fa745e05404025420f- Source checked
- 2026-10-14 · Reviewed against the pinned upstream source
Repository metrics
These values describe the upstream repository, not popularity or likes for an individual skill or playbook.
- Stars
- Not collected
- Forks
- Not collected
- Observed at
- Not collected
No metrics snapshot is available yet.
License: MIT
Main topic
Turn ecommerce campaign materials into a reviewable weekly brief