Skip to main content
Durable Execution enables your agent runs to survive failures and recover automatically. When an error occurs, the agent’s state is preserved, allowing you to resume from where execution left off rather than starting from scratch.

Quick Start

Core Concepts

Error Recovery Flow

  1. Agent starts execution and state is persisted to storage
  2. Error occurs during execution (network issue, API error, etc.)
  3. Agent’s state is saved with error status
  4. continue_run_async() loads the saved state and resumes execution
  5. Execution continues from the last successful checkpoint

Continuation Methods

Recovery with run_id (Same Agent)

Recover from errors using the run_id and same agent instance:

Recovery with task (Same Agent)

Recover from errors using the task object:

Recovery with run_id (New Agent - Cross-Process)

Recover from errors with a new agent instance, simulating cross-process resumption:

Recovery with task (New Agent - Cross-Process)

Recover with a new agent instance using the task object:

Important Notes

  • Retry Configuration: Set retry=1 to disable internal retries when implementing your own retry logic.
  • Direct Call Mode Only: HITL continuation only supports direct call mode. Streaming is not supported.
  • Persistent Storage: Always use persistent storage like SqliteDatabase for cross-process durability.
  • Error Access: Access agent._agent_run_output after an exception to get the run state.
  • Checkpoint-Based: Recovery continues from the last successful checkpoint