Skip to main content

gaas-pydantic-ai

GaaS (Governance as a Service) integration for Pydantic AI (v2).

Every tool call is governed before it executes: the toolset submits a governance intent to GaaS, and only an APPROVE (or an approved escalation) lets the tool run. On BLOCK, GovernanceBlockedError is raised — and because Pydantic AI propagates ordinary exceptions out of agent.run() natively, a blocked action halts the run. No wrappers fighting the framework: this is the framework's own semantics.

pip install gaas-pydantic-ai[pydantic-ai]

Quickstart

from pydantic_ai import Agent
from gaas_pydantic_ai import govern_tools, GaaSGovernanceConfig

def search_web(query: str) -> str:
    """Search the web."""
    ...

def send_email(to: str, subject: str, body: str) -> str:
    """Send an email."""
    ...

config = GaaSGovernanceConfig(api_key="gsk_...", agent_id="my-agent")

agent = Agent(
    "anthropic:claude-sonnet-5",
    toolsets=[govern_tools([search_web, send_email], config=config)],
)

result = await agent.run("Email the Q3 report to finance@acme.com")

Already have a toolset? Wrap it directly:

from gaas_pydantic_ai import govern_toolset

agent = Agent(model, toolsets=[govern_toolset(my_toolset, config=config)])

Verdict flow

tool call → GaaS intent → ┌─────────┐
                          │ APPROVE │ → tool executes
                          │ BLOCK   │ → GovernanceBlockedError aborts agent.run()
                          │ ESCALATE│ → aborts by default; hold-and-poll optional
                          └─────────┘

GovernanceBlockedError is never converted into model-visible text — the adapter deliberately does not use ModelRetry, so the model cannot route around a block.

Configuration

config = GaaSGovernanceConfig(
    api_url="https://api.gaas.is",    # GaaS API endpoint
    api_key="gsk_...",                # Your API key
    agent_id="my-agent",              # Appears in the audit trail
    block_on_escalate=True,           # Raise on ESCALATE (default)
    timeout_seconds=240.0,             # Covers a deliberated decision (30-60 s); fail open on timeout
    sensitivity="INTERNAL",           # Default sensitivity for tool inputs
    raise_on_governance_error=False,  # Fail open if GaaS is unreachable
    extra_regulatory_domains=["HIPAA"],
    extra_data_categories=["PHI"],
    hold_on_escalate=False,           # Wait for the human decision on ESCALATE
    escalation_poll_seconds=5.0,
    escalation_max_wait_seconds=600.0,
)

Hold-and-Poll on ESCALATE

With hold_on_escalate=True, an ESCALATE verdict holds the tool call while GaaS routes the escalation to a human reviewer: approve/modify lets the tool execute; deny raises GovernanceBlockedError (ESCALATE_DENY); timeout raises ESCALATE_TIMEOUT.

Handling blocked runs

from gaas_pydantic_ai import GovernanceBlockedError

try:
    result = await agent.run("wire $250k to the new vendor")
except GovernanceBlockedError as err:
    print(err.verdict)                  # BLOCK / ESCALATE / ESCALATE_DENY / ESCALATE_TIMEOUT
    print(err.decision_id)              # audit reference
    print(err.blocking_policies)        # policy IDs that triggered the block
    print(err.governance_proof_token)   # GPT token ID for the legal audit trail

Release files for gaas-pydantic-ai 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gaas-pydantic-ai 0.1.2
File Size Uploaded
gaas_pydantic_ai-0.1.2.tar.gz 15.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gaas-pydantic-ai 0.1.2
File Interpreter ABI Platform
gaas_pydantic_ai-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 25.2 kB

Release files / gaas_pydantic_ai-0.1.2.tar.gz

Download URL gaas_pydantic_ai-0.1.2.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d26cc870a7f4e07907dc3629cf3cf8cef046fe49e65d2e075375fd3a5c1fdb9f
BLAKE2b-256 checksum
How to use checksums
49284657540a041bde64adf5b36af12f34edb85d0e32198c2e5a4b2d48d673a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / gaas_pydantic_ai-0.1.2-py3-none-any.whl

Download URL gaas_pydantic_ai-0.1.2-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
66252dc78ef0619692985f98a5fb29750d7e8ac267943c18ec4c1873a3e28f43
BLAKE2b-256 checksum
How to use checksums
cb8b3973deb936ddea8fcc38efe5f960e99f5b1ff478e669ec8333370bb6a2b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page