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.

Integrations Claude Code hooks and eight framework adapters

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
FAIL
Execution blocked

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
This browser demo uses scripted examples. Run the Python demo

Architecture

How Recusal governs a tool call

  1. Agent proposes

    The agent proposes a tool call and its arguments. The integration supplies the policy context.

  2. Kernel evaluates

    Recusal applies policy to the supplied evidence and returns PASS, RETRY, or FAIL.

  3. Adapter enforces

    The integration may proceed on PASS, holds for revision on RETRY, and refuses the call on FAIL.

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.

Quickstart

Run the demo locally

Reproduce the two customer writes shown above. After installation, the demo runs offline with no API key.

View the reproducible demo
Terminal
pip install recusal
recusal demo --scenario wrong-subject

# Explore the other scenarios
recusal demo --list