Main
Budgeting by default: add
CostTracking(budget_usd=...)to stop runaway agent loops and to record total tokens/cost per run.Tool permissions: use
ToolGuard(blocked=[...], require_approval=[...])so unsafe tools never appear (or require explicit approval).Input/output controls:
InputGuardblocks risky user prompts early;OutputGuardcan enforce redaction or policy checks post-run.Prefer incremental rollout: start with cost tracking + tool allowlist, then add input/output guards for the highest-risk surfaces.
Source-backed notes
- README shows
pip install pydantic-ai-shieldsand a Quick Start example usingCostTracking,ToolGuard, andInputGuardcapabilities. - README describes
CostTrackingas tracking tokens/cost with optional budget enforcement and raisingBudgetExceededError. - README explains
ToolGuardsupports blocking tools entirely and requiring approvals via a callback.
FAQ
- Is this a full agent framework?: No — README positions it as drop-in capabilities for Pydantic AI, not a separate agent runtime.
- Can I block a tool completely?: Yes — README shows
ToolGuard(blocked=[...])removes tools from the model’s tool list. - What’s the first guardrail to add?: Cost tracking + tool permissions; then add input/output guards for your highest-risk prompts.