Guardian¶
A deterministic security sidecar for LLM agent frameworks.
Guardian is a FastAPI service that runs in a Docker container alongside your agent stack. Every tool invocation is gated through Guardian's 7-check pipeline before it can execute. The checks are deterministic — no LLM in the hot path — so latency is predictable (sub-5ms in practice).
github.com/LegionForge/guardian PyPI: legionforge-guardian
Why a separate sidecar¶
Three reasons Guardian is a separate process rather than a Python library imported into the agent framework:
- Crash isolation. A bug in Guardian shouldn't take down the agent, and vice versa.
- Framework independence. Guardian works with LegionForge but it's not LegionForge-specific. It's designed to drop into any agent framework — LangChain, LangGraph, AutoGen, CrewAI, custom — via HTTP.
- Hot-reloadable rules. Guardian polls the
threat_rulestable every 10 seconds. New rules go live without restarting any agent process.
The 7 checks¶
In order, every tool invocation must pass:
- Tool revocation list — is the tool ID on the revocation list?
- Hash validation — does the loaded tool's code hash match the registered hash?
- Capability boundary — does this task's capability scope include this tool?
- Destructive pattern detection — do the arguments contain known destructive patterns (
rm -rf /,DROP TABLE, etc.)? - Sequence contracts — has the agent violated an ordering rule (e.g., "must call
readbeforedelete")? - Ed25519 signature verification — is the tool's stored signature valid for its stored hash?
- Adaptive threat rules — does the call match any rules loaded from
threat_rules?
Any check that fails → denied. The denial is logged to threat_events as GUARDIAN_DENIED with payload.check_name identifying which check failed.
Pages in this section¶
-
How Guardian fits next to your agent framework, the request flow, the rule storage, the hot-reload mechanism.
-
Detail on each of the 7 checks: what catches it, what payload data it expects, how to extend it.
-
Docker-compose configuration, environment variables, database role setup, health/metrics endpoints.
Status¶
| Version | 0.1.0 (PyPI) |
| License | MIT (independent of the framework's AGPL-3.0) |
| Auto-sync | Public repo auto-syncs from the framework's private dev branch |