Skip to content

Durable Execution

Use durable execution in production when a run in flight has to survive its process stopping, through a deploy, a crash or a transient API failure, or when a workflow waits hours or days for a person or another system. A durable engine journals the agent’s model requests and the tool calls it wraps, and a restarted run replays the completed ones from the journal and retries the one in flight. Which tool calls (function tools, MCP servers) an engine wraps for you and how it delivers streaming differ per engine; each page below says.

Pydantic AI supports eight durable execution engines, plus a builder for any other engine. Each page below has a complete example:

EngineInstallMake an agent durable with
Temporalpydantic-ai-slim[temporal]TemporalDurability from pydantic_ai.durable_exec.temporal
DBOSpydantic-ai-slim[dbos]DBOSDurability from pydantic_ai.durable_exec.dbos
Prefectpydantic-ai-slim[prefect]PrefectDurability from pydantic_ai.durable_exec.prefect
Restaterestate_sdk[serde]RestateAgent from restate.ext.pydantic
AWS Lambdapydantic-ai-harness[aws-lambda]AWSLambdaDurability from pydantic_ai_harness.aws_lambda
Absurdpydantic-ai-harness[absurd]AbsurdDurability from pydantic_ai_harness.absurd
pgtaskpydantic-ai-harness[pgtask]PGTaskDurability from pydantic_ai_harness.pgtask
Apache Airflowapache-airflow-providers-common-aiAgentOperator(..., durable=True) from airflow.providers.common.ai.operators.agent

Temporal, DBOS, Prefect, Restate, and AWS Lambda are co-maintained by the Pydantic and vendor teams. AWS Lambda, Absurd, and pgtask ship in Pydantic AI Harness; Restate and Airflow ship in the engine’s own package.

Capability authors can also move custom hook work into engine activities, steps, or tasks with durable capability operations.

Append-on-change instructions derive their baseline and replacements from persisted history. Instruction callbacks still follow the engine’s replay rules: use a durable operation for external reads so replay uses the same values and produces the same history shape.

Third-party runtime authors can use the stable durable execution backend builder to integrate another engine without importing Pydantic AI internals.

Harness workspace capabilities such as Coder, Shell, and FileSystem also run inside a durable agent; the workspace guide shows how, and what works on each engine.