watchlight-pydantic-ai
Governed Pydantic AI agents with Watchlight — authorize every agent action, fail-closed, with zero infrastructure.
pip install watchlight-pydantic-ai
Independent third-party plugin. This is an independent integration built by Watchlight AI. It is not affiliated with, endorsed by, or sponsored by Pydantic.
Pydantic AIand related names are trademarks of Pydantic, used here nominatively only to describe compatibility.
What it does
watchlight-pydantic-ai puts a Watchlight authorization decision in front of every action your Pydantic AI agent takes — so each tool call is allowed or denied before it runs, never after. It's open-source glue: a thin, framework-specific layer that threads Watchlight's governance primitives into Pydantic AI's @agent.tool decorators and nested Agent.run() composition. The actual policy decisions run on Watchlight's compiled engine — either in-process for local development or against the governed control plane in production.
Quickstart
Point the plugin at a backend and wrap your agent tools with one decorator. Your agent code stays vanilla Pydantic AI — only the backend changes.
For local development, the zero-infrastructure Developer Edition runs the compiled engine in-process (requires the watchlight-engine package):
pip install watchlight-pydantic-ai watchlight-engine
from pydantic_ai import Agent
from watchlight_pydantic_ai import WatchlightPydanticAIPlugin
from watchlight_core import InProcessClient
# A Cedar policy: the research agent may execute web_search, nothing else.
POLICIES = [
{"name": "reader",
"code": 'permit(principal == User::"research-agent", action == Action::"execute", resource == Resource::"web_search");'},
]
plugin = WatchlightPydanticAIPlugin()
plugin.apdp = InProcessClient(POLICIES) # decisions run in-process, no server, no network
agent = Agent("openai:gpt-4o-mini")
async def run_agent(question: str):
async with await plugin.start_run("research-agent") as handle:
@agent.tool
@handle.guarded_tool() # ← the governance line
async def web_search(ctx, query: str) -> list[dict]:
return await fetch(query)
result = await agent.run(question)
return result.output
The @handle.guarded_tool() decorator runs authorize_action("execute", "web_search") against the backend before every invocation of the tool. On a policy denial the decorator raises PermissionError, which propagates up through Pydantic AI's normal tool-error path — the tool body never runs. guarded_tool fails closed: a denial, or an unreachable backend, stops the action.
functools.wraps preserves the wrapped function's signature and docstring, so Pydantic AI's tool-schema introspection works unchanged and the decorator composes cleanly with @agent.tool.
Two backends, same code
| Backend | Runs | |
|---|---|---|
| Developer Edition | InProcessClient |
The compiled engine, in-process — no server, no network |
| Enterprise | ApdpClient |
The governed control plane — signed lineage, drift detection, fleet-wide governance |
Moving from local to production is a one-line change — swap the backend, keep your agent code:
from watchlight_core import ApdpClient
plugin = WatchlightPydanticAIPlugin()
plugin.apdp = ApdpClient("https://apdp.your-company.example", api_key="...")
Links
- Documentation: https://docs.watchlight.ai/de
- Website: https://watchlight.ai
License
Apache-2.0.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file watchlight_pydantic_ai-0.3.0.tar.gz.
File metadata
- Download URL: watchlight_pydantic_ai-0.3.0.tar.gz
- Upload date:
- Size: 56.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc57d40592193bfe3f80a233a3e907fe11d15a024bb3d5059ffd8494d3c2c192
|
|
| MD5 |
d7630b8f6a9670dbab6c0f0d2baa127a
|
|
| BLAKE2b-256 |
23508a7bd46b71c237293f665eeae75ed619a9a836885d95c6553f45a2e414fb
|
Provenance
The following attestation bundles were made for watchlight_pydantic_ai-0.3.0.tar.gz:
Publisher:
publish-python-sdk-plugins.yml on watchlight-ai-beacon/watchlight-beacon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
watchlight_pydantic_ai-0.3.0.tar.gz -
Subject digest:
dc57d40592193bfe3f80a233a3e907fe11d15a024bb3d5059ffd8494d3c2c192 - Sigstore transparency entry: 2590188235
- Sigstore integration time:
-
Permalink:
watchlight-ai-beacon/watchlight-beacon@0764819fb065a45f52f7d3879f8496536e86a805 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/watchlight-ai-beacon
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python-sdk-plugins.yml@0764819fb065a45f52f7d3879f8496536e86a805 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file watchlight_pydantic_ai-0.3.0-py3-none-any.whl.
File metadata
- Download URL: watchlight_pydantic_ai-0.3.0-py3-none-any.whl
- Upload date:
- Size: 35.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1b0f6788141554d81368387e4546e289f05c9928b023f2c2f41a0f045dde493
|
|
| MD5 |
6d40196f8a5c1424bf4d1008c3f13f69
|
|
| BLAKE2b-256 |
ee21471fb2b53d970f3afb517797780482bac62291e842a2a0534cbd955c5364
|
Provenance
The following attestation bundles were made for watchlight_pydantic_ai-0.3.0-py3-none-any.whl:
Publisher:
publish-python-sdk-plugins.yml on watchlight-ai-beacon/watchlight-beacon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
watchlight_pydantic_ai-0.3.0-py3-none-any.whl -
Subject digest:
d1b0f6788141554d81368387e4546e289f05c9928b023f2c2f41a0f045dde493 - Sigstore transparency entry: 2590189424
- Sigstore integration time:
-
Permalink:
watchlight-ai-beacon/watchlight-beacon@0764819fb065a45f52f7d3879f8496536e86a805 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/watchlight-ai-beacon
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python-sdk-plugins.yml@0764819fb065a45f52f7d3879f8496536e86a805 -
Trigger Event:
workflow_dispatch
-
Statement type: