In short.
This guide helps Python developers add failure recovery to Pydantic AI agents with DBOS, but attaching the durability capability alone does not make an agent run recoverable. The documented approach calls agent.run() inside an explicitly registered DBOS workflow and records model requests and MCP communication as database-backed steps. Custom functions, concurrent runs, streaming handlers and application upgrades require additional care. Incorrect concurrency can cause recovery to assign one call's recorded result to another. No examples were executed, and recovery reliability, performance and operating costs remain unassessed.
Researched and written by an AI model and checked by a second AI model. How it works
Covers the complete captured page at [https://pydantic.dev/docs/ai/capabilities/durable_execution/dbos/index.md], including DBOSDurability setup, DBOSAgent deprecation and migration, registration rules, serialization, workspaces, runtime models and capabilities, streaming, cancellation, timeouts, token counting, suspended and background requests, child workflows, concurrency, toolsets, retries and observability. Compatibility warnings are included. Linked pages, repositories and issue contents are excluded. Documentation examples were not executed; recovery correctness, deployment readiness, security, performance and actual costs remain unassessed.
The overview
Identity
This is Pydantic AI's documentation guide to durable execution with DBOS, available at [https://pydantic.dev/docs/ai/capabilities/durable_execution/dbos/index.md]. It teaches an integration between a Python agent framework and a library that stores execution progress in a database.
The recommended integration is the DBOSDurability capability attached to a normal Agent. DBOS runs inside the application process and uses PostgreSQL or SQLite for recorded state. The page also documents migration from the deprecated DBOSAgent wrapper.
Assessment
The guide is useful for developers whose agent applications need to continue after process crashes, network failures or server restarts. It provides unusually specific explanations of recovery hazards, including duplicated side effects, incompatible workflow histories and incorrect result assignment during concurrent replay.
Its main implementation burden is designing code that behaves consistently when replayed. The documentation supports understanding and planning that work, but supplies no measured recovery success rate, throughput, latency or production results. For a small application that can restart its work cheaply, the database and deployment requirements may add more complexity than the recovery benefit warrants.
Users
The primary audience is Python developers already using Pydantic AI for agents that call models, execute tools or communicate with MCP servers. Developers building nested agents, background model jobs or long-running tool sequences have concrete patterns to examine.
Beginners receive installation commands and a small geography-agent example. Applying the guide to a deployed service requires familiarity with asynchronous Python, databases, serialization, retry behavior and application versioning. Developers responsible for streaming interfaces should also examine the difference between live events inside steps and buffered events delivered to workflow code.
Capabilities
Inside a DBOS workflow, DBOSDurability routes model requests and MCP communication through recorded steps. Dynamic toolsets also receive steps for discovery, argument validation when applicable and tool calls. Async function tools can run nested agents in child workflows with separate recovery histories.
The page covers run deadlines, token counting before model requests, suspended model turns, background jobs and batched requests. Waiting between provider polls can use durable DBOS.sleep steps. It also describes database-backed queues with concurrency limits, rate limits, timeouts and priorities.
DBOS workflow and step spans can be combined with Pydantic AI spans through OpenTelemetry and Logfire. These observability features are described without measured overhead or a demonstrated deployment.
Using it
Requirements
The installation options are pydantic-ai[dbos] and pydantic-ai-slim[dbos]. A DBOS system database is required; the example uses SQLite, while the page recommends PostgreSQL for production. Minimum supported Python, Pydantic AI and DBOS versions are not specified.
Construct agents and register their durable capabilities and executing toolsets before DBOS.launch(). Each agent needs a unique name. MCPToolset and DynamicToolset instances need stable identifiers; capability-contributed toolsets derive identifiers from their capabilities. Changing identifiers can break active workflows.
Dependencies and recorded outputs must be serializable. DBOS uses pickle by default and supports a custom serializer. The guide recommends keeping inputs and outputs below approximately 2 MB as performance guidance, rather than a hard storage limit. Model access and any MCP connections also need application-specific configuration, which the example does not fully explain.
Mechanism
A workflow is the replayable control flow around recorded steps. DBOS stores workflow inputs and outputs and step outputs in its system database. During recovery, completed step results can be replayed while workflow code runs again. A failed step starts again from its beginning, so an external action performed before its result was recorded may happen again.
Workflow code must be deterministic and generally cannot perform I/O directly. Model requests, MCP communication and wrapped dynamic-toolset operations have integration-provided steps. Directly registered function tools and ordinary event handlers are not automatically wrapped; developers must place their nondeterministic work and I/O in appropriate steps.
StepConfig controls retries for model requests, MCP communication and the durability event handler; those configurations enable no retries when omitted. The guide recommends disabling transport retries and setting provider SDK max_retries to 0 when DBOS owns retries. Eligible model errors carrying retry_after can move their wait into a durable DBOS.sleep; ordinary step backoff waits remain inside the running process.
Setup
Install with pip install pydantic-ai[dbos] or uv add pydantic-ai[dbos], or use the slim package's dbos extra. Configure DBOS with an application name and system_database_url. Construct a named Agent with capabilities=[DBOSDurability()], then define a function decorated with @DBOS.workflow() that awaits agent.run().
Call DBOS.launch() after registration and invoke the workflow. For the supplied async example, the page explicitly requires importing asyncio and adding asyncio.run(main()). Calling agent.run() outside the workflow still works normally, but does not gain durable execution.
For runtime model selection, model-name strings need no registration. Specific model instances must be registered through the capability's models mapping. A ResolveModelId capability can build models using run dependencies, but its resolver must be deterministic and perform no external I/O.
Example
The introductory example configures sqlite:///dbostest.sqlite and creates a geography agent using the model string openai:gpt-6.1-sol. An answer(question) workflow calls the agent and returns result.output. After launching DBOS, main() asks for Mexico's capital.
The displayed answer, Mexico City, is documentation output rather than an observed result here. The example demonstrates configuration and invocation; it does not demonstrate an interrupted run recovering. Later examples show a research tool running a nested agent in a child workflow and concurrent questions receiving separate workflow histories.
Assessment & evidence
Limitations
Concurrency is a major correctness constraint. Concurrent runs of the same agent within one workflow can start identically named steps in a different order during recovery, causing recorded results to reach the wrong run. Give each concurrent run its own workflow. Parallel tools that interleave multiple durable operations need sequential execution or separate child workflows.
Normal async streaming APIs buffer model events until the model step completes. A DBOSDurability event_stream_handler receives live events inside steps, but its side effects may repeat before checkpointing. Events emitted inside a completed step are not re-emitted when that step's result is replayed. Workflow-side cancellation of an active model stream is unavailable across the durable boundary; external cancellation uses DBOS workflow cancellation.
Most capabilities and executing toolsets must be registered at construction time. Late MCP and dynamic toolsets are rejected. Per-run Instrumentation is an explicit exception to the capability restriction. Child workflows support async FunctionToolset tools with unique identifiers and cannot expose every original context feature.
Stored history can contain workspace commands, call-level environment values, file contents and error conversations. The page advises keeping workspace secrets in the capability's environment configuration and protecting history with an appropriate payload codec. Adding workspace steps, token-count steps or changed event ordering can make existing histories incompatible. DBOS also retries configuration errors when step retries are enabled because it lacks selective non-retryable exception support.
Reasoning
The documented design offers a useful boundary: record expensive or nondeterministic operations as steps, then reconstruct the surrounding agent control flow from saved results. Its recovery benefit depends on preserving that boundary and keeping execution order consistent.
This makes the guide most relevant when developers can make side effects safe to repeat, serialize the required data and control workflow versions. Database checkpoints alone do not establish exactly-once external effects. The page's explicit warnings about silent result reassignment make workflow isolation a correctness requirement for concurrent runs.
Run deadlines also need deliberate interpretation. A run's recorded start time preserves its original deadline through recovery, while a separate DBOS workflow timeout bounds the enclosing workflow. Restarting the application does not necessarily give the agent more time.
Alternatives
The page references Pydantic AI integrations with Temporal and Prefect. It identifies specific differences: DBOS lacks their per-tool step configuration and retries framework configuration errors when retries are enabled, whereas those integrations mark such errors non-retryable. Their broader architecture, cost and performance are not assessed here.
Celery and BullMQ appear as queue systems for which DBOS queues provide a database-backed alternative. The page does not establish that they are interchangeable replacements for the full agent integration. A normal Pydantic AI run remains an option when application-managed recovery is sufficient; DBOSDurability is transparent outside DBOS workflows.
Evidence
The evidence is the complete documentation page at [https://pydantic.dev/docs/ai/capabilities/durable_execution/dbos/index.md], captured on 2026-11-24 at 02:43:33.388 UTC. Its recorded source revision is sha256:5699345b74b57b3303a2618a4c70b9d98cf727ec773a905e5d6d9be3908f11b7.
The page provides installation commands, Python examples, API explanations and compatibility warnings. Linked API references, DBOS documentation, repositories, issue discussions and the accompanying blog article are outside the evidence. No code was executed, so installation success, recovery behavior, provider access, security properties and performance were not independently established.
Access & freshness
Costs
Operating cost is unknown. The page gives no model prices, database hosting prices, Logfire prices or end-to-end usage estimates. Its description of DBOS as open source does not establish the total cost of running an application.
Based on the described architecture, likely cost drivers include model requests, database writes, retained execution data and application hosting. Retries can increase external requests, especially when DBOS, provider SDK and transport retries overlap. The page provides no measurements of checkpoint overhead or savings from replaying completed calls.
Rights
The page calls the DBOS Python library open source and links its repository at [https://github.com/dbos-inc/dbos-transact-py]. The repository's contents and license text are outside the supplied evidence.
The page does not establish the exact licenses, attribution obligations or redistribution conditions for the libraries, documentation or examples. Commercial-use conditions and rights to redistribute captured documentation remain unknown from this page alone. Terms for model providers, MCP services and optional observability services are also not supplied.
Freshness
The capture date establishes the documentation snapshot, but the page supplies no publication date, last-updated date or exact package versions for its examples. Compatibility with a particular installed release therefore remains unknown.
DBOSAgent is marked deprecated and scheduled for removal in v3. Migration requires explicitly wrapping agent.run() in a workflow. Recovering older wrapper workflows additionally requires register_legacy_workflows=True and a pinned DBOS application_version across the deployment, with the flag removed after those workflows finish.
Several changes affect recorded step sequences. The page advises allowing affected in-flight workflows to finish or using an appropriate application version before upgrades. Its reference to different cancellation exceptions in dbos 3.2 and later is a compatibility note, not a minimum-version declaration.
Actions
Begin with the capability-based SQLite example in a development environment and include its missing async entry point. Confirm that every intended durable call enters through a registered DBOS workflow. Inventory custom function tools, event handlers and dynamic factories so their I/O and replay behavior are explicit.
Before relying on recovery, interrupt representative runs and examine whether completed calls are reused, unfinished side effects repeat safely and concurrent runs retain separate results. Evaluate buffered streaming against the intended user experience. These are recommended evaluations; none were performed here.
Before deployment, confirm package compatibility, stable identifiers, database operations, history protection, retry ownership and a strategy for in-flight workflows during upgrades. Obtain exact licenses and current service pricing from the relevant primary sources; neither is established by this page.
