I’m developing a financial assistant using Pydantic AI and need it to pause for approval before executing any transaction over $500. How do I implement a break in the agent's execution flow to wait for a human signal?
3 answers
Pydantic AI facilitates this through its "Durable Execution" and tool approval hooks. You can flag specific tools—like send_payment—as requiring approval. When the agent attempts to call that tool, the framework can pause the execution and save the state. This allows you to expose the pending action to a human via a UI. Once the human approves or modifies the arguments, the agent resumes right where it left off. This is far more secure than just letting an LLM run wild with an API key, as it enforces a programmatic "gate" that must be cleared before the side-effect (the money moving) actually occurs in the real world.
Can the human suggest a correction to the tool arguments during that pause, or is it just a binary yes/no?
It’s essentially a programmatic safety switch that ensures humans stay in the loop for critical business decisions.
Precisely, and the fact that it preserves the conversation context during the pause makes the experience seamless for the end user.
The human can absolutely modify the arguments. Since the state is just a Pydantic object, you can update the proposed values in the pending tool call before sending the "resume" signal back to the agent.