Pre-tool capability · PyPI 0.1.0 · Alpha · Apache-2.0

pydantic-ai-acgs for Pydantic AI.

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.

Caveat: Pre-execution gate after schema validation; does not wrap external side-effect settlement.

Shell · PyPI installation

pip install "pydantic-ai-acgs==0.1.0"

Python · Pydantic AI integration

src/pydantic_ai_acgs/capability.py#L30
from 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.

Verdict.ALLOW

Passes validated tool arguments from after_tool_validate into before_tool_execute.

Verdict.DENY

Raises ToolFailed with the ACGS violation message without consuming the tool's retry budget.

Verdict.REVIEW

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_call

Primary 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.

  1. 01

    Include DeferredToolRequests in output_type if you want review-flagged tool calls to pause the run rather than fail.

  2. 02

    Pydantic AI 2.55+ requires Python 3.11+, while earlier 2.16+ releases support Python 3.10+.

  3. 03

    In the current 0.1.x adapter series, rule evaluation runs through acgs-lite's ToolCallGovernor path. If your workflow requires SignedReceipt, ExecutionGrant, or SQLite EffectStore reservations, 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.