pydantic-ai-middleware and pydantic-ai-shields
These are complementary tools designed to be used together—middleware provides the execution framework and lifecycle hooks for intercepting agent calls, while shields provides the specific guardrail implementations (injection detection, PII filtering, cost tracking) that run within that middleware layer.
About pydantic-ai-middleware
vstorm-co/pydantic-ai-middleware
Middleware layer for Pydantic AI — intercept, transform & guard agent calls with 7 lifecycle hooks, parallel execution, async guardrails, conditional routing, and tool-level permissions.
About pydantic-ai-shields
vstorm-co/pydantic-ai-shields
Guardrail capabilities for Pydantic AI — cost tracking, prompt injection detection, PII filtering, secret redaction, tool permissions, and async guardrails. Built on pydantic-ai's native capabilities API.
Implements guardrails as composable Pydantic AI capabilities rather than external middleware, enabling cost tracking via auto-detected model pricing, prompt injection detection across six attack categories, and concurrent guard execution that cancels LLM calls on early violation detection. Provides both infrastructure shields (tool permissions, custom input/output validation) and content shields (PII regex detection, secret redaction, keyword blocking) that integrate directly into agent initialization without wrapper overhead.
Scores updated daily from GitHub, PyPI, and npm data. How scores work