- Start with human approval: Preview what will be deleted, pause the flow, and manually approve/reject via a UI form
- Graduate to AI autonomy: Switch to an AI agent that investigates system health using Prefect MCP tools and returns structured decisions with confidence scores
Setup
Configuration: Make Cleanup Policy Explicit
Instead of scattering configuration across your code, define it as a structured Pydantic model. This becomes a UI form automatically - see form building guide.Human Approval: Pause and Review
Human Approval: Pause and Review
When using
approval_type="human", the flow pauses and shows a form in the UI.AI Approval: Autonomous Investigation
AI Approval: Autonomous Investigation
When using
approval_type="ai", a pydantic-ai agent investigates using Prefect MCP tools to decide if cleanup is safe.Main Cleanup Flow
Main Cleanup Flow
Deployment Examples
Related Documentation
- Database Maintenance Guide - SQL queries, retention strategies, VACUUM
- Form Building - Create validated UI forms from Pydantic models
- Interactive Workflows - Pause flows and wait for human input
- Prefect MCP Server - Connect AI agents to Prefect
- pydantic-ai + Prefect - Durable AI agents with retries