Skip to main content

Pydantic AI integration for GaaS (Governance as a Service)

Project description

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=5.0,              # Governance check timeout (fail open)
    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

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gaas_pydantic_ai-0.1.0.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gaas_pydantic_ai-0.1.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file gaas_pydantic_ai-0.1.0.tar.gz.

File metadata

  • Download URL: gaas_pydantic_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gaas_pydantic_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1e7c3fafc7b66f4153a908b927078ec82998db1d12491e597c83d6230fd3001b
MD5 c155b76a97160a595acec0662c8e99bd
BLAKE2b-256 8645777c4e4032ccc2da0fce081c0e47956430ed3bb1cdf984c5ba97a148493c

See more details on using hashes here.

File details

Details for the file gaas_pydantic_ai-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for gaas_pydantic_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 157cd3d03c8babf04522be7ef74a8ce42835d6a69c67c58a9ad510a828ee3cec
MD5 191f674a702a8bb8ca0201bd4014b1fe
BLAKE2b-256 bd667c165a51b0d112cf8d4d7a4eaf073e405a81a9f61cd0e4bcfc6cc5263844

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page