In Business Analysis, we often have tasks that take hours or require human input. LangChain has checkpointers for this. Does Pydantic AI support "Durable Execution" so an agent can survive a server restart or wait days for a user to approve a budget before continuing its workflow?
3 answers
Yes, and it’s one of the framework's strongest "production" features. Pydantic AI was designed with durable execution in mind. It uses a snapshotting system that can save the state of the agent's memory and current task to a database. If the process dies or needs to wait for a human, you can re-instantiate the agent from that snapshot. For "Human-in-the-loop" scenarios, it uses specific exceptions that pause the execution and wait for a "resume" signal. We use this for our automated financial auditing; the agent gathers all data, hits a "Review Required" state, and saves everything to PostgreSQL until our analyst clicks 'Approve' in our internal dashboard.
Is the database schema for these snapshots flexible, or are we locked into a specific storage backend?
The integration with Pydantic Logfire also means you can see exactly where an agent "paused" and why, which is a lifesaver for debugging long tasks.
Absolutely. Having that visibility into the "sleeping" state of an agent makes managing hundreds of parallel Business Analysis tasks much more feasible.
It’s very flexible, Bruce. Because the state is just a Pydantic model, you can serialize it to JSON and put it anywhere—Redis, S3, or a standard SQL DB. The framework provides a clean interface for you to implement your own "State Store." We actually use a combination of Redis for quick session memory and S3 for long-term audit logs of the agent's decision-making process.