Pre-tool capability · PyPI 0.1.0 · Alpha · Apache-2.0
pydantic-ai-acgs for Pydantic AI.
Hooks into Pydantic AI tool validation and pre-execution lifecycle callbacks to enforce ACGS-Lite policy rules.
Package Specification · Inspected HEAD b454b55
- Framework maintainer
- Pydantic · pydantic.dev
- Upstream repository
- pydantic/pydantic-ai
- PyPI release
- pydantic-ai-acgs==0.1.0
- Python requirement
- >=3.10
- Framework constraint
- pydantic-ai-slim>=2.16.0,<3
- Governance engine pin
- acgs-lite>=3.0.1,<4
- Integration mechanic
- Pre-tool veto / intervention hook
- Hook entry point
- ACGSCapability.after_tool_validate / before_tool_execute
01 · Local Setup & Quickstart
Attach governance to one tool-calling agent.
Install the pinned release from PyPI alongside acgs-lite>=3.0.1,<4. Rule evaluation uses deterministic keyword and regex matching locally in Python—no external model or network call is made by the governance check.
Shell · PyPI installation
pip install "pydantic-ai-acgs==0.1.0"Python · Pydantic AI integration
src/pydantic_ai_acgs/capability.py#L30from pydantic_ai import Agent, DeferredToolRequests
from pydantic_ai_acgs import ACGSCapability
agent = Agent(
"openai:gpt-5.2",
capabilities=[ACGSCapability()],
output_type=[str, DeferredToolRequests],
)02 · Verdict & Review Mapping
How ACGS-Lite verdicts map to Pydantic AI.
When a tool call is proposed, the adapter formats the tool name and arguments via format_tool_call and evaluates them against the configured Constitution. Blocking rules always take precedence over review rules.
Passes validated tool arguments from after_tool_validate into before_tool_execute.
Raises ToolFailed with the ACGS violation message without consuming the tool's retry budget.
Raises ApprovalRequired so Pydantic AI emits a DeferredToolRequests output for human-in-the-loop approval.
03 · Public API Surface
Exported symbols and source entry points.
Each adapter keeps its public surface minimal and re-exports the shared GovernanceDecision, Verdict, and ToolCallFormatter types alongside the framework-specific hook or middleware class.
__all__ exports · pydantic-ai-acgs
src/pydantic_ai_acgs/capability.py#L30 ↗ACGSCapabilityMETADATA_KEYGovernanceDecisionToolCallFormatterVerdictformat_tool_callPrimary hook surface: ACGSCapability.after_tool_validate / before_tool_execute. Custom ToolCallFormatter functions may be supplied if your tool arguments require custom canonical serialization before rule matching.
04 · Scope & Bypass Boundaries
What this adapter does and does not cover.
Verify these framework-specific boundaries when integrating pydantic-ai-acgs into an evaluation workflow.
- 01
Include DeferredToolRequests in output_type if you want review-flagged tool calls to pause the run rather than fail.
- 02
Pydantic AI 2.55+ requires Python 3.11+, while earlier 2.16+ releases support Python 3.10+.
- 03
In the current
0.1.xadapter series, rule evaluation runs throughacgs-lite'sToolCallGovernorpath. If your workflow requiresSignedReceipt,ExecutionGrant, or SQLiteEffectStorereservations, wire those contracts explicitly at the tool executor boundary.
Put one real workflow under your control.
Choose one tool. Define what it may do. Inspect what happens when a request crosses the boundary.