Product

A capability system for agent tool use.

Aegis is not a firewall for LLM output. It is a deterministic policy engine that runs in-process between your agent and the MCP servers it calls. It decides which calls may run and records why.

How it works

Two phases, one trust boundary

The design rests on one rule: anything that reads untrusted text must never be able to change the policy. So the one component that uses an LLM runs before the agent reads anything at all.

PHASE 1 · BEFORE THE RUN

Propose, validate, freeze

The user's request is trusted input. propose_spec() sends it to an LLM once, and the LLM drafts the smallest spec that covers the task. The spec is checked against a strict schema, hashed with SHA-256, and frozen.

You can skip the LLM completely: load_spec() reads YAML an operator wrote and needs no API key.

PHASE 2 · DURING THE RUN

Evaluate every call

The agent runs normally. Each tool call goes through evaluate(), a pure, synchronous function with no I/O, no network calls and no LLM import. It returns a verdict, a reason and the rule that fired. The audit record is written before the agent gets the result.

Tool output can't change the policy, because nothing in this path treats it as instructions.

The engine

Nine ordered rules. The first DENY wins.

The model is a closed world at every level. If a server, tool or argument isn't listed, it's unknown, and unknown means denied. Rules 1–8 decide ALLOW or DENY. Rule 9 runs on top of that result, and it can only narrow it.

Full contract
01
Server not listed
The call targets a server that isn't in servers:. rule-1-server-not-listed
DENY
02
Tool not listed
The server is listed but the tool isn't. rule-2-tool-not-listed
DENY
03
Zero-arg tool called with args
A tool with no args block was given arguments. rule-3-zero-arg-violation
DENY
04
Zero-arg tool, zero args
A genuinely argument-free call, such as list_allowed_directories.
ALLOW
05
Required argument missing
The spec names an argument and the call left it out, so its value can't be checked. rule-5-missing-required-arg
DENY
06
Extra argument
The call includes an argument the spec doesn't name. Injected parameters can't ride along on a valid call. rule-6-extra-arg
DENY
07
Value not allowed
Values must match must_match_one_of exactly. Lists are checked one element at a time, empty lists are denied, and types the engine can't reason about are refused. rule-7-*
DENY
08
All checks pass
A clean pass has matched_rule: null. A pass that relied on a waiver says which waiver it was.
ALLOW
09
Intercept overlay
If the call is allowed and its (server, tool) pair is in intercepts, it pauses for human approval. A DENY can never be rescued this way. rule-9-intercept-required
INTERCEPT

Outcomes

Three verdicts, and every one leaves a record

ALLOW

The call goes to the MCP server. An ok record is written with latency and a redacted preview of the result. If a waiver made the pass possible, its rule id is recorded too.

DENY

The server never sees the call. A denied record is written with the reason and matched rule, and a PermissionError goes back to the agent.

INTERCEPT

The call pauses. Your approval_callback decides, or AegisApprovalRequired is raised so you can handle approval out of band. Approved calls are marked intercepted: true.

Fail closed

If the policy evaluator itself throws an error, the call is denied and a policy_evaluation_error record is written. When the security layer breaks, the safe result is a refusal.

Components

Two pieces. Only one is required.

REQUIRED

The library

A Python package that wraps any Pydantic AI toolset in one line. It checks every tool call against a capability spec, pauses sensitive calls for human approval, scans responses for leaked secrets and writes a local JSONL audit log.

pip install and nothing else. Works standalone.

OPTIONAL

The control plane

A self-hosted FastAPI and Postgres backend. It collects audit records from all your agents in one place so you can query them: rebuild any run, list every refused call, and see which policy version made each decision.

docker compose up. It is never in the enforcement path. If it's unreachable, tool calls are still evaluated and decisions are still correct.

Forensics

Every record answers "which policy said so?"

Records share a run_id, so one search rebuilds a whole run. Each governed call carries the spec_hash of the exact YAML that decided it, even if the file on disk has changed since. Tool content is redacted in every audit field, whatever the inspection mode, so the log can't become the leak.

Waivers stay visible. A call allowed because an operator set allow_any is recorded as rule-7-bypassed-allow-any, not as an ordinary pass.

Audit record reference
logs/audit.jsonl
{
  "call_id": "6f1c…",
  "ts": "2026-09-15T10:42:07.112Z",
  "run_id": "a9e3…",
  "status": "denied",
  "server": "filesystem",
  "tool": "read_text_file",
  "args": { "path": "/sandbox/project-update.txt" },
  "reason": "arg 'path' value … not in capability spec",
  "matched_rule": "rule-7-value-not-allowed",
  "spec_hash": "4b1d…"
}

Design decisions

Why it is built this way

Exact matching only
Globs, regex and path normalisation are where traversal bypasses come from. Requiring an exact string removes that whole class of bugs, so there's nothing to sanitise.
Deny by default
deny_all_others defaults to true. To turn it off, the task text must contain the string deny_all_others=false, so a weaker setting is always a deliberate choice.
Validated at load time
A spec that fails validation never reaches evaluate(). The hot path only ever handles specs that are known to be valid.
Intercepts are operator policy
The proposer never writes intercept rules. Which calls need a human is a risk decision for the operator, and can't be inferred from a task description.
Control plane observes only
No code in the control plane can affect an enforcement decision. This is a permanent design boundary, not a limit of version 1.

See the engine decide.

The playground runs the same rules in your browser. Edit a spec, fire a call and read the audit record Aegis would write.