Open-source policy enforcement
Policy before execution.
The agent proposes. Policy decides.
Recusal checks AI tool calls against your policy. At each tool boundary you connect, it can stop an unapproved action before the tool runs.
Interactive demo
What happens at the gate?
This example shows a proposed tool call, the policy finding, and the resulting verdict.
RC-2049 · Subject mismatch
- Agent
- Proposes
- Recusal
- Evaluates policy
- Tool
- Not invoked
The target customer differs from the authorized customer.
Proposed call
{
"tool": "customer.update",
"customer_id": "cust_B",
"authorized_customer": "cust_A"
}
Policy finding
Policy: customer_scope Expected: cust_A Observed: cust_B
Architecture
How Recusal governs a tool call
Agent proposes
The agent proposes a tool call and its arguments. The integration supplies the policy context.
Kernel evaluates
Recusal applies policy to the supplied evidence and returns
PASS,RETRY, orFAIL.Adapter enforces
The integration may proceed on
PASS, holds for revision onRETRY, and refuses the call onFAIL.
Trust boundary. Local enforcement depends on protecting hooks, policies, and credentials. The repository documents an isolated enterprise reference design. Read the security model
The kernel
Deterministic by design
The same policy and evidence produce the same verdict. The decision path runs in Python 3.9+ with zero runtime dependencies.
Read the implementation guide- Explicit outcomes
- Callers can distinguish permission, revision, and refusal in code.
- Tamper-evident audit records
- Verdict records form a hash chain. Detecting truncation or wholesale rewriting requires an external anchor.
- MCP capability integrity
- Pin approved descriptions and tool declarations to detect changes in the catalog presented to the gate.
Integrations
Eight framework adapters
Each adapter connects its framework’s tool boundary to the same policy kernel.
CrewAI
recusal-crewai
Google ADK
recusal-google-adk
LangChain
recusal-langchain
LangGraph
recusal-langgraph
OpenAI API
recusal-openai
OpenAI Agents
recusal-openai-agents
OpenAI Agents + MCP
recusal-openai-agents-mcp
Pydantic AI
recusal-pydantic-ai
Recusal also supports native Claude Code hooks and MCP tooling. See tested integrations and coverage
Quickstart
Run the demo locally
Reproduce the two customer writes shown above. After installation, the demo runs offline with no API key.
pip install recusal
recusal demo --scenario wrong-subject
# Explore the other scenarios
recusal demo --list