Skip to main content

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

Release files for intercept-ai 0.3.0

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

Source distribution (sdist)

Source distribution for intercept-ai 0.3.0
File Size Uploaded
intercept_ai-0.3.0.tar.gz 17.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for intercept-ai 0.3.0
File Interpreter ABI Platform
intercept_ai-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 35.0 kB

Release files / intercept_ai-0.3.0.tar.gz

Download URL intercept_ai-0.3.0.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b59d2c32ceee9863ee3db4883311f24829d1e4545ec57b70a0fc075b05d5e91a
BLAKE2b-256 checksum
How to use checksums
00b551753540e5606f864195af549be01df69b0177e5332e049a8a2eec8ecd30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release files / intercept_ai-0.3.0-py3-none-any.whl

Download URL intercept_ai-0.3.0-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1550216be44ef5717067531704424ee033e05393b3e6c699c8d87e7c9992f4e8
BLAKE2b-256 checksum
How to use checksums
1f4d95f55c724f52513260beffe281aa1b6161de48de103fea6ee68fbb7b1246
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

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