Runtime enforcement layer for autonomous AI agents — intercepts tool calls, classifies risk, enforces policies, and controls execution.
Project description
Interceptor
Runtime enforcement layer for autonomous AI agents.
Interceptor intercepts tool calls before execution and applies policy enforcement, risk classification, role-based approval, and execution control — so your AI agents never run unchecked.
Installation
pip install intercept-ai
Optional Integrations
# For LangChain support
pip install "intercept-ai[langchain]"
Or install from source:
git clone https://github.com/interceptor/interceptor.git
cd interceptor
pip install -e ".[dev]"
Quick Start
from interceptor import Interceptor
guard = Interceptor(mode="strict")
decision = guard.run(
tool_name="delete_file",
args={"path": "/tmp/data.csv"},
user_role="user",
)
print(decision.allowed) # False
print(decision.risk_level) # HIGH
print(decision.decision) # blocked
Console output:
┌──────────── INTERCEPTOR ────────────┐
│ Risk: HIGH │
│ Mode: strict │
│ Decision: blocked │
│ Intent: Agent intends to call │
│ delete_file with │
│ path=/tmp/data.csv │
│ Reason: HIGH risk action requires │
│ admin approval. │
└─────────────────────────────────────┘
Strict Mode
guard = Interceptor(mode="strict")
# HIGH → blocked (unless admin)
# MEDIUM → confirmation required
# LOW → allowed
Balanced Mode
guard = Interceptor(mode="balanced")
# HIGH → confirmation required
# MEDIUM → allowed with warning
# LOW → allowed
Observe Mode
guard = Interceptor(mode="observe")
# Never blocks — logs risk and intent only
YAML Policy
Create a policy.yaml:
tools:
delete_file:
risk: HIGH
write_file:
risk: MEDIUM
keywords:
- drop
- overwrite
Load it:
guard = Interceptor(mode="strict", policy_path="policy.yaml")
Role-Based Approval
# Blocked for regular users
decision = guard.run("delete_file", {"path": "/data"}, user_role="user")
assert not decision.allowed
# Allowed for admins
decision = guard.run("delete_file", {"path": "/data"}, user_role="admin")
assert decision.allowed
Override Tokens
token = guard.generate_override_token()
decision = guard.run(
"delete_file",
{"path": "/data"},
user_role="user",
override_token=token,
)
assert decision.allowed # one-time bypass
LangChain Integration
Secure any LangChain tool in one line:
from langchain_core.tools import tool
from interceptor import Interceptor
from interceptor.integrations.langchain import InterceptedTool
@tool
def delete_database(db_name: str):
"""Deletes a database."""
return f"Deleted {db_name}"
guard = Interceptor(mode="strict")
safe_tool = InterceptedTool(tool=delete_database, guard=guard)
# If an agent tries to call this without admin role:
# result = "Error: This action was BLOCKED by security policy..."
Async Support
Interceptor supports async def tool calls and asynchronous confirmation callbacks.
@intercept(guard)
async def async_tool(data: str):
await some_io_operation(data)
# Or manually
decision = await guard.arun("tool_name", {"arg": "val"})
Session Reports
Get an intelligent summary of your agent's behavior at the end of a session:
guard.print_report()
This generates a colorful terminal dashboard with an Agent Score, threats caught, and smart tips to save LLM tokens.
License
MIT
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 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 intercept_ai-0.3.0.tar.gz.
File metadata
- Download URL: intercept_ai-0.3.0.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b59d2c32ceee9863ee3db4883311f24829d1e4545ec57b70a0fc075b05d5e91a
|
|
| MD5 |
e7da57cdf78099b054f50f8f88545585
|
|
| BLAKE2b-256 |
00b551753540e5606f864195af549be01df69b0177e5332e049a8a2eec8ecd30
|
File details
Details for the file intercept_ai-0.3.0-py3-none-any.whl.
File metadata
- Download URL: intercept_ai-0.3.0-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1550216be44ef5717067531704424ee033e05393b3e6c699c8d87e7c9992f4e8
|
|
| MD5 |
2b073af5b959cb2c6ecb0102ef48b930
|
|
| BLAKE2b-256 |
1f4d95f55c724f52513260beffe281aa1b6161de48de103fea6ee68fbb7b1246
|