Skip to main content

Open source agent security

Agent Airlock

By Sattyam Jain, updated . On AgentDojo it blocks 86.0% of injection-to-target tool calls, as a deterministic bound rather than a model-in-the-loop rate (run ).

An in-process contract layer for AI agent tool calls.

Agent Airlock is an open-source Python library that checks each AI agent tool call before the tool runs. One decorator validates the arguments against the function's own signature in Pydantic strict mode, strips arguments the model made up, and applies the policy you set: allowed tools, roles, rate limits and budgets. A refused call comes back as a structured error with fix hints the model can retry on, not a traceback. It runs inside your process, not as a proxy or gateway. Sattyam Jain builds and maintains it; v0.13.0 was released on under Apache-2.0.

  • 13,839 tests
  • 92.34% coverage
  • 169 releases
  • v0.13.0

Install and wrap a tool

From agent-airlock on PyPI (opens in a new tab). The decorator is the whole integration; adapters cover 12 agent frameworks, among them LangChain, LangGraph, the OpenAI Agents SDK, PydanticAI, CrewAI, Google ADK and FastMCP.

bash, then Python
pip install "agent-airlock>=0.10.3"

from agent_airlock import Airlock

@Airlock()
def transfer_funds(amount: int, to: str) -> str:
    return f"Sent ${amount} to {to}"

If the model sends amount="500", the call is refused (strict mode does not coerce a string to an int). If it adds force=True, that argument is stripped before the function sees it.

What it checks

A fixed sequence of gates runs before your function, and sanitising runs after it. Validation, output sanitising, the audit log and a startup-hook check are on by default; the rest is opt-in.

Validate
Pydantic V2 strict mode on every argument, with no type coercion. Arguments that are not in the function's signature are stripped, and a refused call returns fix hints the model can retry against.
Authorize
Role-based access, token-bucket rate limits, time windows, per-model-tier cost budgets and capability gating.
Isolate
Filesystem path checks, network egress allowlists by host and path prefix, and sandboxed execution.
Sanitize
PII and secret masking, output truncation and a JSON-Lines audit log.
MCP guards
Per-CVE guards for stdio injection, OAuth, DNS rebinding, SSRF and other MCP server flaws, tracking MCP spec revision 2026-07-28.

Measured results

Every Airlock arm in these runs uses SecurityPolicy(default_deny=True) with only the tools the task needs on its allowlist, not the library defaults, and no run uses an adaptive attacker. Null results are published beside the wins.

What it does not do

  • Prompt injection is not detected, only contained.
  • It checks a call before it runs and cannot undo a call that ran. It ships no approval channel; you wire one to Slack, a ticket queue or a prompt.
  • By default an empty allowlist allows every tool. Set default_deny=True on the SecurityPolicy to refuse tools that are not listed.
  • No benchmark run uses an adaptive attacker.

Related on this site