Runtime policy enforcement for AI agents
Project description
AgentProof
Runtime policy enforcement for AI agents. One line to protect your users.
AgentProof ensures your AI agents never take unauthorized actions. Write policies in the Aegis language, compile them, and enforce them at runtime with <10ms latency.
Install
pip install agentproof
Requires Python 3.9+. The package includes a pre-compiled Rust native extension — no Rust toolchain needed for installation.
Quick Start
OpenAI
from agentproof import enforce
import openai
client = openai.OpenAI()
safe_client = enforce(client, policy="guard.aegisc")
# Use exactly as before — AgentProof intercepts every tool call
response = safe_client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Check the weather"}],
tools=[...],
)
If the agent tries to call an unauthorized tool:
agentproof.EnforcementError: AgentProof: External HTTP calls are not permitted
LangChain
from agentproof import AgentProofCallbackHandler
handler = AgentProofCallbackHandler(policy="guard.aegisc")
agent = create_react_agent(llm, tools, callbacks=[handler])
Direct Engine
For custom frameworks or advanced use cases:
from agentproof import PolicyEngine
engine = PolicyEngine.from_file("guard.aegisc")
result = engine.evaluate("tool_call", {
"tool": "http_request",
"url": "https://api.external.com/data",
"method": "POST",
})
print(result.verdict) # "deny"
print(result.reason) # "External request to unapproved destination"
print(result.eval_time_us) # 42 (microseconds)
Decorator
Wrap individual tool functions:
from agentproof import intercept_tool_call
engine = PolicyEngine.from_file("guard.aegisc")
@intercept_tool_call(engine)
def send_email(to: str, subject: str, body: str):
...
Writing Policies
Policies are written in the Aegis language and compiled with the aegisc CLI:
policy DataGuard {
severity high
scope tool_call, data_access
on tool_call {
when event.tool contains "http"
deny with "External HTTP calls blocked"
}
proof NoDataLeaks {
invariant InternalOnly {
always(
none(context.tool_calls, c =>
c.url starts_with "http://external"
)
)
}
}
}
aegisc compile guard.aegis -o guard.aegisc
The compiler transforms temporal invariants (always, eventually, until, never) into deterministic state machines. At runtime, the verifier advances these automata on every event — no regex, no string matching, no validators. Mathematical guarantees.
How It Works
Agent → tool call → AgentProof intercepts → Policy engine evaluates → Verdict
↓
allow / deny / audit / redact
- Your agent decides to call a tool
- AgentProof intercepts the call and builds an event
- The compiled policy is evaluated against the event (<10ms)
- A verdict is returned: allow, deny (with reason), audit (log but allow), or redact (allow with sanitized fields)
- The decision is logged to an immutable audit trail
Enforcement Modes
The enforce() wrapper supports three modes:
# Raise an exception on deny (default)
safe_client = enforce(client, policy="guard.aegisc", on_deny="raise")
# Block silently (same behavior, different semantics)
safe_client = enforce(client, policy="guard.aegisc", on_deny="block")
# Monitor mode — log denials but allow all actions
safe_client = enforce(client, policy="guard.aegisc", on_deny="log")
Monitor mode is useful for deploying AgentProof alongside an existing agent to see what would be blocked before turning on enforcement.
Dependencies
The base package has zero Python dependencies beyond the compiled Rust extension. Framework integrations are optional:
pip install agentproof[openai] # adds openai>=1.0
pip install agentproof[langchain] # adds langchain-core>=0.1
Fail-Closed Design
If the Rust engine returns an error or the pyo3 bridge fails for any reason, the default behavior is to deny the action, not allow it. This is a security product — silent failures must not become silent permissions.
Building from Source
If you want to build the native extension yourself:
# Prerequisites: Rust stable toolchain + maturin
pip install maturin
# Build in development mode
cd agentproof-python
maturin develop
# Run tests
pytest
Part of AgentProof
This SDK is the Python interface to AgentProof's compiler and runtime verifier. The full project, including the Aegis language specification, is at github.com/ScottsSecondAct/agentproof.
License
Apache 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 aegis_enforce-0.1.0.tar.gz.
File metadata
- Download URL: aegis_enforce-0.1.0.tar.gz
- Upload date:
- Size: 93.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c5c62bf99d4c83f10fbe1681ae529fc655b1aa9bbf50608b7c1be9901319ecd
|
|
| MD5 |
a5a2b221370414988d9a864de5cd21df
|
|
| BLAKE2b-256 |
44853ed9d40a7d35b6ea27713ba0209e38a15241e939c8ac8a175a2adec03d09
|
Provenance
The following attestation bundles were made for aegis_enforce-0.1.0.tar.gz:
Publisher:
release.yml on ScottsSecondAct/AgentProof
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aegis_enforce-0.1.0.tar.gz -
Subject digest:
2c5c62bf99d4c83f10fbe1681ae529fc655b1aa9bbf50608b7c1be9901319ecd - Sigstore transparency entry: 1203793503
- Sigstore integration time:
-
Permalink:
ScottsSecondAct/AgentProof@aff2b9dd006d5ca32a212031c37d751d8d9199a8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/ScottsSecondAct
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@aff2b9dd006d5ca32a212031c37d751d8d9199a8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file aegis_enforce-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: aegis_enforce-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 596.6 kB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e5b3883d3883c8692a427ef58390964e626769b2e541b26944620fbdae08f7e
|
|
| MD5 |
0f833d1889070b16f408ced59d210185
|
|
| BLAKE2b-256 |
35d66a6bda0348931148b8681050d883dbdaa3a9b0ba2b15d23da62a949f9113
|
File details
Details for the file aegis_enforce-0.1.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: aegis_enforce-0.1.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 438.1 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81c6e90a48ccb9c1289a2ec25f3b804709fe9e0199389e48e44b18e82baa218f
|
|
| MD5 |
71cb762f0ca2e944a61a1410a341f1c7
|
|
| BLAKE2b-256 |
0984d89b7ac36ce04ecd5f6c45b7e1e5043ff5c464e5a97be7565bbe7cf68b88
|
Provenance
The following attestation bundles were made for aegis_enforce-0.1.0-cp311-cp311-win_amd64.whl:
Publisher:
release.yml on ScottsSecondAct/AgentProof
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aegis_enforce-0.1.0-cp311-cp311-win_amd64.whl -
Subject digest:
81c6e90a48ccb9c1289a2ec25f3b804709fe9e0199389e48e44b18e82baa218f - Sigstore transparency entry: 1203793593
- Sigstore integration time:
-
Permalink:
ScottsSecondAct/AgentProof@aff2b9dd006d5ca32a212031c37d751d8d9199a8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/ScottsSecondAct
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@aff2b9dd006d5ca32a212031c37d751d8d9199a8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file aegis_enforce-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: aegis_enforce-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 608.6 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce0716fa15d3c2d5e5a3294f050068645c47d6aebcda5df2bcc3670bb79cde3e
|
|
| MD5 |
ee2ee8eda644004c0cb6dc57fe3a7790
|
|
| BLAKE2b-256 |
10c4051da11d15363b67cc7e213059a237567c9a67b142a26fcaf08d659d0235
|
Provenance
The following attestation bundles were made for aegis_enforce-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on ScottsSecondAct/AgentProof
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aegis_enforce-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
ce0716fa15d3c2d5e5a3294f050068645c47d6aebcda5df2bcc3670bb79cde3e - Sigstore transparency entry: 1203793537
- Sigstore integration time:
-
Permalink:
ScottsSecondAct/AgentProof@aff2b9dd006d5ca32a212031c37d751d8d9199a8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/ScottsSecondAct
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@aff2b9dd006d5ca32a212031c37d751d8d9199a8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file aegis_enforce-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: aegis_enforce-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 583.5 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f551fd4a2a5902f307013d4ffd3cdd13b10a677661b430e90d4a466360b4c62
|
|
| MD5 |
518c19804c8da83716d7cc6c6e133ef4
|
|
| BLAKE2b-256 |
3f2744921eeddc959f94fdea730ebb2d17eccc60a8f7e783f94b14ac1c883831
|
Provenance
The following attestation bundles were made for aegis_enforce-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on ScottsSecondAct/AgentProof
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aegis_enforce-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
4f551fd4a2a5902f307013d4ffd3cdd13b10a677661b430e90d4a466360b4c62 - Sigstore transparency entry: 1203793569
- Sigstore integration time:
-
Permalink:
ScottsSecondAct/AgentProof@aff2b9dd006d5ca32a212031c37d751d8d9199a8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/ScottsSecondAct
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@aff2b9dd006d5ca32a212031c37d751d8d9199a8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file aegis_enforce-0.1.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.
File metadata
- Download URL: aegis_enforce-0.1.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.11, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41bcf2469de4e3d20b0383415f9188d999891e5d243a5fc2a6c3ee15fd3b4241
|
|
| MD5 |
9ef509fc8863602e3aec282277e49332
|
|
| BLAKE2b-256 |
f2653565b12015f5641986bb8f5ef7505afc40e144107a7efb1e189a492add16
|
Provenance
The following attestation bundles were made for aegis_enforce-0.1.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:
Publisher:
release.yml on ScottsSecondAct/AgentProof
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aegis_enforce-0.1.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl -
Subject digest:
41bcf2469de4e3d20b0383415f9188d999891e5d243a5fc2a6c3ee15fd3b4241 - Sigstore transparency entry: 1203793524
- Sigstore integration time:
-
Permalink:
ScottsSecondAct/AgentProof@aff2b9dd006d5ca32a212031c37d751d8d9199a8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/ScottsSecondAct
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@aff2b9dd006d5ca32a212031c37d751d8d9199a8 -
Trigger Event:
push
-
Statement type: