Skip to main content

recusal, deterministic governance for AI agents

recusal-google-adk

PyPI CI python license

The Recusal gate for Google ADK: every tool call an agent proposes is judged by your policy before the tool runs, and a refused call never runs.

New to Recusal? It checks each tool call an AI agent proposes against your policy and refuses the unsafe or unapproved ones before the tool runs. No model makes that decision. A policy is a plain Python function: it is given the tool's name and its arguments and returns a list of findings. An empty list lets the call run; a failing finding refuses it and gives the reason. Writing a policy covers the two postures, allowlist and deny-list.

Before the tool runs. An agent proposes a tool call. Recusal, your policy with no model in it, decides. With no objection the tool runs. On a failing finding, or when the policy itself raises, the call is refused: the tool never runs and the reason goes back to the model. Every decision can be written to a hash-chained audit log, if you pass one.

This is a separate distribution from recusal. The kernel has zero runtime dependencies and a frozen compatibility perimeter; this package carries the ADK dependency and its own version, so an ADK release never forces a release of the kernel.

Install it from PyPI:

pip install recusal-google-adk

Requires Python 3.11+ (the ADK's minimum), recusal>=0.14.0 and google-adk>=2.14.0. It is tested on every pull request against exactly google-adk==2.14.0 with google-genai==2.34.0, and weekly against the newest releases.

The package ships inline types (py.typed) for your editor and type checker.

Use

from google.adk.agents import LlmAgent
from recusal import Finding
from recusal_google_adk import gated_agent


def policy(tool_name, tool_input):
    sql = tool_input.get("sql", "")
    if tool_name == "run_sql" and sql.lstrip().upper().startswith("DELETE"):
        return [Finding.fail("no_deletes", severity="CRITICAL", message="DELETE is not allowed")]
    return []


agent = gated_agent(LlmAgent(name="assistant", model=model, tools=[run_sql]), policy)

gated_agent returns a copy of the agent with the gate appended as the last before-tool callback, and gates its sub_agents and the agent behind every AgentTool the same way. A refused call is answered to the model as {"error": reason}. The tool does not run. A policy that raises refuses the call (fail closed).

The gate prepares the invocation the way the ADK will (defaults completed, values validated), judges a detached copy, and the tool runs with exactly what was judged.

For an app whose agents you do not build yourself, RecusalPlugin(policy) is the same gate as a runner plugin: InMemoryRunner(agent, plugins=[RecusalPlugin(policy)]). Plugin callbacks run before any agent's own, so the plugin judges a call only when nothing it cannot see runs after it. If the executing agent has another before-tool callback, or a later plugin overrides before_tool_callback, it refuses the call and names the fix.

Put every decision on the record

from recusal.audit import AuditLog
from recusal_google_adk import audited_agent

log = AuditLog(path="decisions.jsonl")
agent = audited_agent(LlmAgent(name="assistant", model=model, tools=[run_sql]), policy, log)

audited_plugin(policy, log) is the plugin form. Each call a gate sees, allowed or refused, is one hash-chained entry labeled google_adk.before_tool_callback with the ADK's function call id and a SHA-256 fingerprint of the arguments (never the arguments). If the log cannot be written the call is refused. Check the log with recusal audit verify decisions.jsonl.

The audited forms are the plain ones with a recording passed in, so there is one decision path.

What the gate refuses, and what it does not see

  • gated_agent raises at construction for an agent that can run something the callback never sees: an agent with a code_executor (model-written code runs outside the tool path), an LlmAgent subclass, or an agent class it does not know how to gate.
  • Refused before the policy runs: a tool that is not a stock FunctionTool, a signature that cannot be judged by name, an unknown or missing parameter, and arguments that do not validate.
  • Not on the audit log: a call another before-tool callback answered before the gate ran. The tool did not run either.

Compatibility

This package is outside the kernel's frozen perimeter (STABILITY.md, Integrations). Its public names are the ones in recusal_google_adk.__all__. When an ADK release changes what the callback is handed, this package gets a release and the kernel does not.

A runnable offline demonstration, with a scripted model and no API key, is examples/google_adk_gate.py and examples/google_adk_audit.py.

More

One kernel, eight adapters. Each adapter package depends on recusal: recusal-crewai, recusal-google-adk, recusal-langchain, recusal-langgraph, recusal-openai, recusal-openai-agents, recusal-openai-agents-mcp and recusal-pydantic-ai. recusal-langchain also depends on recusal-langgraph, and recusal-openai-agents-mcp on recusal-openai-agents. The kernel depends on nothing.

An arrow means "depends on". No arrow leaves the kernel, so a framework's breaking change is answered by a release of that framework's adapter, not by a release of the kernel.

Licensed under Apache-2.0.

Metadata

Release files for recusal-google-adk 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for recusal-google-adk 0.1.2
File Size Uploaded Provenance Actions
recusal_google_adk-0.1.2.tar.gz 16.4 kB With provenance Details for recusal_google_adk-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for recusal-google-adk 0.1.2
File Interpreter ABI Platform Actions
recusal_google_adk-0.1.2-py3-none-any.whl Python 3 none any Details for recusal_google_adk-0.1.2-py3-none-any.whl

Total release size: 32.5 kB

Release files / recusal_google_adk-0.1.2.tar.gz

Download URL recusal_google_adk-0.1.2.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f1204f6db5619e16e1e59056e7f2157e7fa7d88dd511040a659d3cc93d59aadb
BLAKE2b-256 checksum
How to use checksums
5c3309531a6167be79379c1b0a5db9de837d2382cc1d9adfed605620daa8089e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / recusal_google_adk-0.1.2-py3-none-any.whl

Download URL recusal_google_adk-0.1.2-py3-none-any.whl
Size 16.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed03ce761fe0d6d41cd5ccc17ab8d2799bcf09f1bc2d3c8bf7e733badf2008bd
BLAKE2b-256 checksum
How to use checksums
11d9ca75f24a25a2452250aec852d3e0933b344301e44ad76fef4953bef70dba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for recusal-google-adk 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for recusal_google_adk-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page