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.
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.
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.
servers:. rule-1-server-not-listedrule-2-tool-not-listedrule-3-zero-arg-violationlist_allowed_directories.rule-5-missing-required-argrule-6-extra-argmust_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-*matched_rule: null. A pass that relied on a waiver says which waiver it was.(server, tool) pair is in intercepts, it pauses for human approval. A DENY can never be rescued this way. rule-9-intercept-requiredOutcomes
Three verdicts, and every one leaves a record
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.
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.
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.
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.
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.
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.
{
"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
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.evaluate(). The hot path only ever handles specs that are known to be valid.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.