actionguard
Policy-as-code for AI agent tool calls, in Rust — the pattern security teams already use for cloud infrastructure (OPA/Rego, AWS Cedar: a policy decision point in front of every action, deny-overrides, fail-closed by default) applied to agent tool calls instead of API requests. guardflow validates what an agent says; actionguard validates what it's about to do, before it does it.
Install
Usage
use ;
use ;
let policies = new
.with
.with
.with;
let call = new;
match policies.check
Fail-closed by default: if no policy explicitly allows a call, it's denied — the same default OPA and every serious authorization system ships with, and the opposite of what most hand-rolled "if command contains rm" checks do.
Deny-overrides: any policy voting Deny blocks the call outright, even if another policy voted Allow — you can't accidentally allowlist your way past an explicit deny rule.
Async policies
For checks that need a model call — "does this action match what the user actually asked for" (see Intent-Governed Tool Authorization) — AsyncPolicy wraps an async closure, evaluated only after every sync policy has already voted:
use AsyncPolicySet;
use CustomAsyncPolicy;
let policies = from_sync.with_async;
Examples
Benchmarks
cargo bench (benches/overhead.rs):
| Scenario | Time |
|---|---|
PolicySet::check, 3 policies, allowed |
~104 ns |
License
MIT