Skip to main content

recusal, deterministic governance for AI agents

recusal-google-adk

Website PyPI CI OpenSSF Scorecard 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.18.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 (defaults completed, values validated against the function's types whatever the ADK's own validation setting), judges a detached copy, and the tool runs with exactly what was judged, apart from the parameters the ADK fills itself (see below). A parameter whose default is None and that the call leaves out or sets to null is judged as None, and runs as None: it is written into the call when a wrapper on the way declares another default for it. A decorator whose own code fills or changes an argument (kwargs.setdefault(...)) is the tool's code, which no gate reads. A value that does not validate against its type ("abc" for an int) is refused, naming the parameter. When a None has to be written into the call (a wrapper declares another default) and the ADK's FUNCTION_TOOL_ARG_VALIDATION is on, a parameter not declared Optional is refused, since the ADK would refuse the None. A wrapper with its own default over a pydantic.validate_call function that rejects None fails the call; nothing runs.

For an app whose agents you do not build yourself, RecusalPlugin(policy) is the same gate as a runner plugin, given to the app: InMemoryRunner(app=App(name="shop", root_agent=agent, plugins=[RecusalPlugin(policy)])) (from google.adk.apps import App). 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. A plugin is handed tool calls only, so before a run starts it checks every agent in the tree, from the root (a continued session can start at a sub-agent and transfer anywhere), with the same rules gated_agent applies, and refuses the whole run when one of them can execute something no callback sees: a code_executor, a provider-side tool, a toolset, a task or single_turn sub-agent, or an agent class it does not know. It also refuses a run whose RunConfig sets support_cfc, which gives the agent the model provider's code execution.

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 (and is_gated is False) 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, an agent class it does not know how to gate, and any tool that is not a function, a FunctionTool or a plain AgentTool. That includes the built-in tools the model provider runs on its own side (google_search, url_context, VertexAiSearchTool and the like), which never reach a callback, tools declared in generate_content_config, and toolsets (MCP, OpenAPI), whose tools it cannot judge. Two ADK tools that run locally are accepted: preload_memory (it only adds memory to the model request) and load_artifacts (whose calls the gate refuses, since it cannot judge them). An agent in task mode is refused: the gate cannot judge how it finishes its task.

  • gated_agent cannot see how you run the agent. It is handed the agent, not the RunConfig: do not set support_cfc, which gives the agent the model provider's code execution. RecusalPlugin sees the run and refuses it.

  • Refused before the policy runs: a FunctionTool whose class or object replaces any method on its run path (preparing, filtering, confirming or calling), or whose function was replaced after it was built; a signature that cannot be judged by name, including a functools.wraps wrapper that adds a parameter of its own or names one the function it wraps also takes; a parameter the ADK fills itself that the tool takes as a positional-only one (def lookup(tool_context, /, table: str): the ADK passes it by position, below); an unknown or missing parameter; arguments that do not validate, or that validating again would change.

  • A decorated tool whose wrappers cannot all be read. Whether a tool can be judged is the kernel's answer, and since 0.2.3 all of it is: the gate asks recusal.invocation.judged_parameters the way the ADK calls a tool (every judged value by keyword, nothing by position ahead of them, the parameters the ADK fills left out, and every parameter of the tool's own asked by name first), completes the call from the defaults that gives, and passes on the kernel's reason for a refusal (refusal_reason), whole and alone: what was found, what to write instead, and why a plain function that calls the refused one does not remove the cause. Every judged value is written into the call the ADK makes, a default the model left out too, a None among them: what the policy saw is, name for name, what is passed. The gate holds no rule and no reason of its own for a decorated tool, and reads no default, no kind of parameter and no wrapper; 0.2.2 held three rules and a reason for each class of refusal. Three things it still learns of the tool otherwise than from the kernel, each through the ADK's own object: which parameters the ADK fills itself, from the names the ADK keeps for the tool (FunctionTool._ignore_params), which it hands the kernel as the names to leave out; the types of its parameters, from the ADK's record of the tool (FunctionTool._spec), to validate the values as the ADK's own validation does; and whether a parameter the ADK fills is positional-only, which it does not read but infers, from whether the function the ADK calls is the tool's own (FunctionTool._get_compatible_func, below). Two refusals for a tool are worded by this gate and not by the kernel: that one ("Make it a parameter a keyword can fill"), and the ADK's validation refusing a None ("declare the parameter Optional"). The kernel reads every callable a call reaches and refuses what it cannot follow to the end. Refused:

    • a decorator that holds a second wrapper of the function (in its closure, in a module global it names, or on the decorator object) and calls it, where the held wrapper has a parameter of its own, takes the tool's parameters in other places, takes the object of a method under another name than the function it wraps has for that place, or reaches the function through a single-dispatch function, a weak proxy or a cache named again;
    • a functools.lru_cache named again for another function, whose function cannot be told from what the cache refers to;
    • a functools.singledispatch function or singledispatchmethod on the way, with an implementation registered, or with nothing registered but its base (one can be registered between the check and the call);
    • a functools.partialmethod over a callable object or a class-based decorator;
    • a wrapper handed a bound argument (the object of a method, a positional argument of a functools.partial) that takes it under another name than the function it wraps has for that place: its signature does not show whether it hands the argument on;
    • a declared signature, also where it matches the real parameters: a __signature__, a __text_signature__ that is not the interpreter's own, or a callable object that shows a __code__ and names nothing as __wrapped__;
    • a weakref.proxy anywhere on the way;
    • a callable that answers for __wrapped__ without holding one (a class-based decorator that hands every attribute on with __getattr__), or that shows another class than its own and has a __call__ of its own that takes a parameter by name;
    • a class-based decorator that is also a descriptor (its class defines __get__);
    • more wrappers than the walk reads;
    • a functools.partial as the tool, and a tool whose annotations typing.get_type_hints cannot resolve;
    • by a rule this gate had of its own in 0.2.2 and the kernel has since recusal 0.18.0 (judge_tool, which the walk alone does not ask), the one recusal-pydantic-ai has: a method whose decorator's wrapper takes the object in the place of the method's own and names the method's other parameters itself, where the values it names could move up a place and leave a parameter with a default to fill (def wrapper(self, table, limit=10) over def purge(self, table: str, limit: int = 10)). The kernel's walk reads it by design, and the ADK calls it by keyword, so its named parameters take the judged values: with return fn(table, limit) in its body, 0.2.2 as first prepared gated it, judged {table: "t", limit: 5}, and ran self="t", table=5, limit=10. Refused also under functools.wraps(fn) written above a functools.lru_cache of that wrapper. Every name the wrapper takes after the object counts, a keyword-only one too (def wrapper(self, *, account, amount=7, memo="m0") over def transfer(self, account: str, amount: int = 7, memo: str = "m0"), whose body return f(account, amount, memo) ran self="ACCT", account=55, amount="MEMO" as the review of 0029945 found), under an ordinary decorator, a cache, a functools.partial helper of the bound method or a free facade over it as well. Where that parameter has no default, the method has no keyword-only parameter with a default either, and the wrapper gives no parameter a default the method does not have, the stack is read: no value can move into a place that would run at a default, and a wrapper that kept the object and handed every value on fails the call with a TypeError, so nothing runs. Since 0.2.3 a keyword-only parameter with a default counts as such a place too (def w(self, account, *, amount=7, memo="m0") over def transfer(self, account: str, *, amount: int = 7, memo: str = "m0"), which 0.2.2 stated as open: with return f(account, amount) in its body it was gated, judged {account: "ACCT", amount: 55, memo: "MEMO"}, and ran self="ACCT", account=55, amount=7, memo="m0"). Write the wrapper with *args and **kwargs after the object and hand them on with it (def wrapper(self, *args, **kwargs): return fn(self, *args, **kwargs)), which is read.
    • by the same rule, a method decorator that holds a second wrapper of the method and calls it with the object, where the held wrapper takes the object under the method's own name (def inner(self, account, amount=7, memo="m0")), whether the decorator's own wrapper is outer(self, *args, **kwargs) or a plain outer(*args, **kwargs): the kernel looks at what the callables on the way hold (their closures, the globals they name, a decorator object's attributes), and what each held functools.wraps wrapper holds and names in turn, and refuses a held functools.wraps wrapper that takes the object under the method's own name and names parameters after it, whatever it wraps; one whose __call__ is not a function written in Python, so that its parameters cannot be read; and, past 512 held callables in one walk, the tool as it stands. Not counted as held: what the walk itself stands on or steps through, such as the function a wrapper decorates, which the walk reads as its next level (a decorator stacked above a wrapper that restates the method's parameters is read, as that wrapper is alone); the walk of the method's function with the object unbound also refuses one under outer(self, *args, **kwargs) that takes only *args and **kwargs after it, and, since 0.2.3, whatever else that walk refuses: under a decorator that keeps the object (def outer(self, *args, **kwargs): return inner(*args, **kwargs)), a held wrapper that takes the tool's parameters by position (def inner(sql="x", force=False)), which 0.2.2 read. Give the held wrapper *args and **kwargs alone, the object taken in *args with the rest (def inner(*args, **kwargs)), which is read.
    • by the rule recusal-pydantic-ai has for it: a wrapper that takes a parameter of the function under another kind than the function's (def w(self, account, amount, memo="m0") over def transfer(self, account: str, amount: int, *, memo: str = "m0"), where the count above leaves nothing empty: with return f(account, amount, memo) it ran self="ACCT", account=55, amount="MEMO" as the confirmation review of b0384a1 found). Give a method's wrapper only *args and **kwargs after the object; over a plain function, the function's parameters with the function's own kinds, order and defaults are read too.
    • new with recusal 0.18.0, each by a rule the kernel asks for every framework: a functools.partial that binds a value by position and is named for what it wraps with functools.wraps or functools.update_wrapper (the value it binds is not in the signature the parameters are read from); and a wrapper that gives a parameter a default that is not the function's own. The kernel's entry for 0.18.0 in the changelog has the whole of its rules.

    Read to the end, so that a wrapper with a parameter of its own is refused, naming the parameter, and one that only passes its arguments on is accepted: functools.wraps wrappers and functools.lru_cache applied directly, @functools.wraps(f) written above @functools.lru_cache, and a class-based decorator built with functools.update_wrapper (on a method, a class-based decorator with no __get__ and a functools.partial do not bind the object, and its self is refused as not annotated). A decorator written as functools.wraps(f)(functools.partial(helper, f)), which 0.2.2 read to the end, is refused since 0.2.3 (above). No reason advises calling the refused function from a plain function and registering that one: the gate reads a plain function's parameters and never its body, so the cause would run inside it as before.

  • How the ADK calls a tool, and what that means for a shifted call. The ADK passes every argument by keyword: FunctionTool.run_async hands the prepared arguments to _invoke_callable (google/adk/utils/_sync_runner.py in google-adk 2.14.0), which calls target(**kwargs), and the tool context is one of those keywords, put in under the name of the parameter the ADK found for it (FunctionTool._prepare_invocation_args). Nothing goes by position but the object of a method, with one exception: for a function with a positional-only parameter the ADK calls a wrapper of its own that turns the keywords for such parameters back into positions (_make_keyword_compatible in google/adk/tools/function_tool.py), so a context the tool takes as tool_context, / goes by position, ahead of the judged values. The gate refuses such a tool, and says to make the parameter one a keyword can fill. So for every tool it judges, what the gate tells the kernel is true: the call style is by keyword, no argument leads the judged ones, and the context's name is left out. Where the kernel refuses a wrapper that may keep a bound argument because a call by keyword would then fail and a call by position would run each judged value one place off, a call the ADK makes would fail with a TypeError, and nothing would run: under the ADK such a tool, refused, either runs correctly or fails. The kernel's reason for a bound argument can advise taking the argument under the name the function has for it and passing it on by position. Where another wrapper on the way keeps the object (a method decorator that does not pass self on), the tool written that way is gated and does not run as judged, and the reason says so itself, for the ADK's call: it raises a TypeError.

  • Agent tools: a call to a plain AgentTool is judged as the sub-agent receives it (the request text, or the arguments as JSON), and only when the sub-agent's own tool calls are judged too: it is gated (gated_agent gates it), or it inherits RecusalPlugin (include_plugins=True, the default, with the plugin on the app). Otherwise the call is refused. An AgentTool whose agent declares an input_schema, an AgentTool subclass, and the tools ADK makes for sub-agents in single_turn or task mode are refused.

  • Not judged: an agent's answer. The gate judges tool calls, not what an agent says. A structured answer (output_schema) is the agent's output either way it arrives: the set_model_response call the ADK adds when the agent has tools, which runs nothing and passes without the policy, or the final text, which no callback sees. Judge whatever acts on the answer (the next agent's tool calls are judged by their own gate).

  • Not judged: the parameters the ADK fills itself, tool_context and input_stream. A call that sets either is refused; outside a live run an input_stream parameter takes its own default, which is the tool's code.

  • Not on the audit log: a call another before-tool callback answered before the gate ran (the tool did not run either), and a set_model_response call, which is the agent's answer and passes without the policy.

  • Provider options on the model: a model object that passes its provider an option turning on the provider's own tool, LiteLlm(..., web_search_options=...), also when nested (extra_body), or an OpenRouter web plugin in its options, is refused, in a FallbackModel too. Other provider options and model names are configuration the gate does not read, and a model that searches on its own is the model's choice.

Refused although it runs correctly. The kernel's walk reads parameters and not bodies, so it refuses some signatures a correct tool can have. Each of these runs correctly under the ADK, which calls it by keyword, and beside recusal 0.18.0 each is refused, before the policy is asked and before anything runs. 0.2.1 beside recusal 0.15.1 gated each of the first four parts, and 0.2.2 beside recusal 0.18.0 gated each of the last. Each was run through this gate, and so was each remedy below.

  • New with recusal 0.16.0:

    • A __text_signature__ that matches the parameters. Delete it.
    • A decorator written as functools.wraps(g)(functools.partial(helper, g)) over g = Binding(f), where Binding is a class-based decorator whose class defines __get__: the walk follows the __wrapped__ the partial carries and refuses the descriptor. Give Binding no __get__ and call functools.update_wrapper(self, fn) in its __init__, and write the decorator's wrapper as a function of its own (the last part of this list).
    • A class-based decorator that keeps the function in an attribute and answers every other attribute from it with __getattr__, over a plain function, which then shows its __code__. Call functools.update_wrapper(self, fn) in its __init__.
    • A facade method that passes a value of its own in the place of the first parameter of the function it wraps (return search("acme", *args, **kwargs) over def search(tenant: str = "main", sql: str = "", limit: int = 10)), where that parameter has a default. Give the agent the function itself, or write the method out, its parameters passed on to the function by keyword.
    • A class method whose function is a cache named again for a cache of it (functools.update_wrapper(functools.lru_cache(...)(lambda *a, **k: cached(*a, **k)), cached)), under a decorator written as functools.wraps(f)(functools.partial(helper, f)): the walk reports cls as a parameter the tool does not declare, as it does for the same class method without the partial, which 0.2.1 refused too. Cache the function once, without the cache that is named again, and write the decorator's wrapper as a function of its own (the last part of this list).
  • New with recusal 0.17.0:

    • A weakref.proxy of a plain function under a decorator that hands its arguments on. Put the function in the proxy's place.
    • A single-dispatch method that nothing is ever registered on (the object goes in by position, so the call dispatches; a bare single-dispatch function called by keyword, as the ADK calls a tool, fails). Make the method the base function itself.
    • A class-based decorator that answers every other attribute with __getattr__, over a function that names a __wrapped__ (any functools.wraps decorator, any functools.lru_cache). Call functools.update_wrapper(self, fn) in its __init__.
    • A decorator that holds a weakref.proxy of a helper. Hold the helper itself.
    • A decorator that holds a wrapper which takes the tool's parameters in another order and hands them on by keyword: the ADK's call by keyword reaches each by name. Give the held wrapper the tool's parameters in the tool's order, or as keyword-only ones.
  • New with recusal 0.17.1:

    • A method decorator that takes the object under another name than the method has for it and hands it on (def wrapper(this, *args, **kwargs): return m(this, *args, **kwargs) over def run_sql(self, ...)). Take the object under the name the method has for it (self, or cls for a class method) and hand it on by position.
    • A held functools.wraps wrapper that does the same (def forward(receiver, *args, **kwargs): return run(receiver, *args, **kwargs) over def run(self, ...), called by a pass-through). Take the object in *args with the rest.
    • A held helper whose chain of __wrapped__ comes back on itself (helper.__wrapped__ = helper). Name the function it wraps, once.
    • The same facade as under 0.16.0 where that parameter has no default (def search(tenant: str, limit: int = 10)). Give the agent the function itself, or write the method out.

    Refused too, and changing nothing that runs, since the ADK's call fails there either way: such a wrapper that drops the object where the place it leaves has no default (def method(self, *args, **kwargs): return execute(*args, **kwargs) over def execute(database: str, ...), and a held def forward(receiver, *args, **kwargs): return run(*args, **kwargs)). 0.2.1 beside recusal 0.17.0 gated both, and the call raised TypeError. The kernel's entries for 0.16.0, 0.17.0 and 0.17.1 in the changelog have the whole lists for its walk.

  • New in 0.2.2, by a rule of this gate's own then, which is the kernel's since 0.2.3 (above):

    • A method decorator whose wrapper takes the object as self and names the method's parameters itself, and hands the object on (def wrapper(self, table, limit=10): return fn(self, table, limit)), over a method with a positional parameter that has a default. Write the wrapper with *args and **kwargs after the object and hand them on with it.
    • The same wrapper with the method's parameters as keyword-only ones (def wrapper(self, *, account, amount=7, memo="m0"): return f(self, account, amount, memo)): its signature is that of the one that drops the object. The same remedy.
    • A method decorator that holds a second wrapper of the method and calls it with the object, where the held wrapper takes the object as self and hands it on: one that names the method's parameters, under outer(self, *args, **kwargs) or a plain outer(*args, **kwargs), and one that takes only *args and **kwargs after it, under outer(self, *args, **kwargs). Give the held wrapper *args and **kwargs alone (def inner(*args, **kwargs): return fn(*args, **kwargs)).
    • A wrapper that takes a parameter of the function under another kind than the function's and hands it on correctly (def w(sql="", *, limit=10): return fetch(sql, limit) over def fetch(sql: str = "", limit: int = 10)). Give it the function's own kinds, order and defaults.
    • A method decorator whose body merely names a module-level functools.wraps function that takes the object's name and a parameter (if False: audit_note(self, "x") in def logged(self, *args, **kwargs), where audit_note = functools.wraps(note)(...) takes (self, note)), though it never calls it: the look at what a wrapper holds counts every held functools.wraps wrapper that takes the object's name, whatever it wraps. Keep the helper out of the decorator's body. (Beside recusal 0.17.0 and 0.17.1, naming the helper's first parameter otherwise, def audit_note(obj, note), was read too; beside 0.17.2 the kernel refuses that as well, for the helper's own parameter note.)
    • A method decorator that holds, or whose code names, more than 512 callables: the look at what it holds stops there, and a tool it could not read to the end is refused, whatever it holds. Keep the decorator's own code to the wrappers it calls.
  • New in 0.2.3, beside recusal 0.18.0, each by a rule the kernel asks for every framework (0.2.2 beside the same kernel gated each, and it ran as judged):

    • A decorator written as functools.wraps(f)(functools.partial(helper, f)), the partial of a helper named for the function, which 0.2.2 read to the end: a functools.partial that binds a value by position and is named for what it wraps is refused, whatever it binds. Write the decorator's wrapper as a function of its own (@functools.wraps(f) over def wrapper(*args, **kwargs): return helper(f, *args, **kwargs)).

    • A wrapper that restates the function's parameters with a default that is not the function's own and hands each value on (def w(sql="", limit=99): return fetch(sql, limit) over def fetch(sql: str = "", limit: int = 10); 0.2.2 wrote the function's default into the call, so the wrapper's never applied). Give the wrapper the function's own defaults, or only *args and **kwargs.

    • A method decorator that keeps the object and calls a held wrapper which takes the tool's parameters by position (def outer(self, *args, **kwargs): return inner(*args, **kwargs) holding def inner(sql="x", force=False), which passes an object of its own to the method's function). Give the held wrapper the tool's parameters as keyword-only ones, or *args and **kwargs alone.

    • A held class-based wrapper whose __call__ is not a plain method (a staticmethod, as run here), named for the function with functools.update_wrapper and called by a decorator that holds it: on a method, and on a plain function too where a class-based decorator stands in the same stack, above it or under it. Its parameters cannot be read from a code object, so whether it takes the place of an argument bound on the way cannot be told. Write its __call__ as a method (def __call__(self, *args, **kwargs)).

    • A keyword-only method wrapper that hands the object on, over a method whose own parameters are keyword-only (def w(self, *, account, amount=7, memo="m0"): return transfer(self, account=account, amount=amount, memo=memo)). Write the wrapper with *args and **kwargs after the object and hand them on with it.

    • A method wrapper with the method's own kinds that hands the object on, where a keyword-only parameter has a default (def w(self, account, amount, *, memo="m0"): return f(self, account, amount, memo=memo)). The same remedy.

    • A wrapper with a fixed signature that leaves out a parameter of the function whose default is None (def w(sql=""): return lookup(sql) over def lookup(sql: str = "", region: str = None)): 0.2.2 left the None for Python to fill, and the call ran as judged; the kernel refuses a fixed signature that leaves a parameter of the function out. Give the wrapper every parameter of the function, or only *args and **kwargs.

    • A parameter the ADK fills itself that the tool takes as a positional-only one (def lookup(tool_context: ToolContext, /, table: str, limit: int = 5)), by a refusal of this gate's own: the ADK passes it by position, and the gate judges a tool only where the ADK passes everything by keyword. Make it a parameter a keyword can fill (no / after it).

    • A wrapper that restates the function's parameters in another order and hands each on by keyword (def swapped(limit, table): return lookup(table=table, limit=limit) over def lookup(table: str, limit: int = 5)): the ADK's call by keyword reaches each by name, and the kernel refuses a fixed signature that takes the function's parameters in another order, for every call style. Give the wrapper the function's own order, or only *args and **kwargs.

    • A decorator that names the ADK's context in its own signature (tool_context, the name this was run with) beside the *args or **kwargs it hands the rest on with, stated here as a family and not shape by shape. Such a decorator is refused whether it hands the context on or not; whether it takes it as a keyword-only parameter (def wrapper(*args, tool_context, **kwargs)) or as an ordinary one (def wrapper(tool_context, **kwargs)); with a default or with none; and over a function that takes the context as an ordinary parameter, as a keyword-only one, with a default or with none, or not at all (def audited(*args, tool_context=None, **kwargs): return lookup(*args, **kwargs) over def lookup(table: str, limit: int = 5)). One form is read: the decorator takes the context as a keyword-only parameter with no default, and so does the function (def wrapper(*args, tool_context: ToolContext, **kwargs) over def lookup(table: str, *, tool_context: ToolContext)). A functools.wraps wrapper that restates the function's whole signature, with no *args or **kwargs, is not part of the family. In the forms tried, one that takes the context as the function does is read, as under 0.2.2, and so is one that takes it keyword-only with no default where the function gives it a None default; one that takes it under another kind, with a default the function does not give, or although the function does not take it is refused, where 0.2.2 read it. Restate it as the function has it, or take the context in **kwargs as below. The same holds for input_stream, the other name the ADK fills: in the forms tried, a decorator that names it beside *args or **kwargs is refused in the same ways, and taking it in **kwargs is read; the differential runs the family with tool_context only. 0.2.2 read every form: its own rules left out the names the ADK fills, and the kernel's rules for a parameter a wrapper takes under another kind, names and also forwards, or takes although the function does not have it hold for those names too. Take the context in **kwargs with the rest and hand it all on (def wrapper(*args, **kwargs), reading kwargs.get("tool_context") where the decorator needs it), which is read over every such function; or write both in the one form above.

    A None default is written into the call. 0.2.2 left a None default the model did not send for Python to fill, where every callable its walk read declared None for it, and wrote it in otherwise. 0.2.3 writes it in always, since it reads no callable's defaults itself and the kernel does not hold every callable's to the function's (it reads a wrapper that restates a parameter with no default, and a held wrapper with another). Three things follow, each for a call that leaves out a parameter whose default is None. The first two are for a parameter declared with a type that does not admit None (region: str = None), and declaring it Optional[str] removes both. First, with the ADK's own argument validation on (FUNCTION_TOOL_ARG_VALIDATION, off by default), which refuses a None for a str, the call is refused, naming the parameter: "the ADK's own validation refuses None for region; declare the parameter Optional". 0.2.2 gave that refusal only where it wrote the None, and ran the call otherwise. Second, a function behind pydantic.validate_call does not validate its own default and does reject a None that is passed: the call is judged and allowed, and then raises a ValidationError, so nothing of the function runs. 0.2.2 ran it. The gate cannot see such a decorator, so it cannot refuse the call first. The third is for a tool built with a callable require_confirmation, whatever the parameter's type, and declaring it Optional does not remove it: the ADK hands that callable the same arguments the tool is called with (FunctionTool.check_require_confirmation), so one that does not take every parameter of the tool (def needs(amount: int) over def pay(amount: int, memo: Optional[str] = None)) is handed the written memo=None: the call is judged and allowed, and the ADK's call of needs raises a TypeError, so nothing of the tool runs. 0.2.2 ran it where the model left memo out; where the model sends memo, the same call fails with no gate at all. The gate cannot hand the callable another dict than the tool's. Give the callable every parameter of the tool, or **kwargs (def needs(amount: int, **rest)).

    Measured against 0.2.2. python tools/differential/google_adk.py --summary puts the same tools to the gate as released (read out of git at the tag recusal-google-adk-v0.2.2) and to this one, both beside recusal 0.18.0 and google-adk 2.14.0, and counts the difference: the 55 rows of the kernel's shared table of decorator shapes, 210,600 calls of generated stacks of one to three decorators (36 decorators over 9 functions, each called with every parameter given and with a default left out), 240 calls of the family of decorators that name the ADK's context (8 decorators, each alone, under a pass-through and over one, over 5 functions), and every call the adapter's own test files make to the gate. The table, the stacks and the family are compared twice, with the ADK's own argument validation off, its default, and on; the tests' calls once, at the default. In neither is a tool that 0.2.2 refused read by 0.2.3, are the arguments judged for a tool both read any other, or are the arguments 0.2.3 writes for the ADK's call anything but the ones it judges. With the validation off, 0.2.3 newly refuses 3 rows of the table and 5,564 of the generated calls: 1,633 ran as judged, 2,725 raised and 1,206 ran a value no policy judged under 0.2.2. With it on, 0.2.3 newly refuses 3 rows of the table and 5,625 of the generated calls: 1,651 ran as judged, 2,755 raised and 1,219 ran a value no policy judged under 0.2.2. Of the 240 calls of the context family, 228 are newly refused under either setting (150 ran as judged with no gate and 78 raised) and 12 are read by both, the one form the page says is read. (Each was called by keyword with no gate, with the arguments 0.2.2 wrote. The ones that ran as judged are refused although they run correctly, by the causes above; where the call raised, nothing ran under 0.2.2 either.) --list prints each. tests/test_differential_google_adk.py runs the short form of it, the table and the stacks of one and two decorators and the whole context family, under both settings, in the Google ADK jobs of CI. The script says at its top what it does not show: it compares the two gates on these tools and no others, no wrapper among them tells a parameter left out from a None, no function among them validates its own arguments or has a confirmation callable, and a tool both gates read is not shown by it to run as judged.

Open, stated so you can judge them. A test named test_open_ holds each.

  • A method decorator that forgets to pass the object on. @functools.wraps(m) def method(self, *args, **kwargs): return m(*args, **kwargs) over def run_sql(self, sql: str, force: bool = False), and the same where the decorator takes the object in *args (return m(*args[1:], **kwargs)) or over a class method's cls. It is gated, and the policy judges the call; the ADK calls it by keyword, so the method is missing its object, the call raises a TypeError, and none of it runs. Called by position, as other frameworks call a tool, it would run every judged value one place off. From the signature nothing tells it from the ordinary decorated method, which the kernel's entry for 0.17.1 states under "Still read, by design". Pass self on in the decorator.
  • The same, where the place the object leaves has a default. A facade that drops its object in *args over def execute(database: str = "main", sql: str = "SELECT 1", note: str = "") is gated, and called by keyword database runs at its default, which no policy judged; the judged values run in their places. Hand the object on, or give the agent the function itself.
  • A method wrapper that names the method's parameters with the method's own kinds and defaults and drops the object, where no parameter it could leave has a default: def wrapper(self, table): return purge(table) over def purge(self, table: str). Read. The ADK's call fails with a TypeError, and nothing runs. Where a positional or a keyword-only parameter has a default such a wrapper is refused (above; 0.2.2 read the keyword-only case and stated it here).
  • A held wrapper without functools.wraps that takes the object under another name and drops it (def forward(receiver, *args, **kwargs): return run(*args, **kwargs), called by a functools.wraps pass-through): the kernel reads it by design, since every correct held wrapper written without functools.wraps has the same shape. It is gated, and the ADK's call raises a TypeError. The same with functools.wraps is refused.
  • A wrapper whose body hands the values on in other places than its signature names them. Over a plain function, @functools.wraps(fn) def wrapper(database, sql="SELECT 1"): return fn(sql) names the function's parameters and is read; the ADK's call by keyword gives each judged value to the wrapper by name, and its body runs fn(database="Q") for judged {database: "D", sql: "Q"}. This is the decorator's own code, which no gate reads, as kwargs.setdefault(...) is (above); on a method, where the place moved out of is the object's, the rule above refuses it. So is a body that asks whether a parameter was left out: since 0.2.3 every judged default is written into the call, so if "limit" in kwargs in a **kwargs wrapper is always true for a judged parameter, and a body that turns a None it finds there into another value runs that value (judged {query: "q", limit: None}, it ran limit=-1; 0.2.2 left the None out, and it ran None).
  • A held wrapper the kernel's walk does not find. One that names nothing as __wrapped__, with a parameter of its own, runs that parameter at its default, which no policy judged. So does a held class-based wrapper, named for a plain function with functools.update_wrapper, whose __call__ is a staticmethod with a parameter of its own: its parameters cannot be read from a code object, and it is refused only on a method. (A wrapper that a functools.partial binds as an argument under a functools.wraps of the function, functools.wraps(f)(functools.partial(helper, wrapper)), which 0.2.2 stated here, is refused since 0.2.3: the partial is.) The kernel's entry for 0.17.0 lists the other held wrappers its walk does not find (one built on first use, one in a slot, a container, a settings object or a function's own attribute, one behind a weakref.ref).

Beyond the gate. This gate judges the tool calls the framework routes through it; the paths around it inside the framework are listed above. Like every Recusal gate, it does not stop an agent that can reach a resource another way: a credential with wider rights, a shell or network path outside the agent, or a file it can write that configures the gate. Use it as one layer of several: least-privilege credentials for the agent, a sandbox or container, limits on its network egress, and an audit anchor the writer cannot reach (the limits in full).

Status

In-depth review complete. Its fixes are released in 0.2.2. 0.2.3, which moves the reading of a decorated tool to the kernel, came after that review and has not been through one. Recusal is a Beta (0.x) open-source project in active development: it is not a finished or certified security product, and it is provided under Apache-2.0 without warranty. What the reviews are, and where every adapter stands.

What 0.2.3 changes. It requires recusal 0.18.0 (0.2.2 allowed 0.17.1), and the reading of a decorated tool is the kernel's alone: the gate asks judged_parameters by keyword, as the ADK calls a tool, and passes on refusal_reason. The three rules 0.2.2 had of its own (a method decorator that names the method's parameters and may drop the object, a held wrapper that names the object's place, a wrapper that takes a parameter under another kind), its own completion of defaults and its own reason for each class of refusal are gone from this package; the kernel asks those rules for every framework. So the words of every refusal for a decorated tool change (they are the kernel's, which say what was found and what to write instead), and more tools are refused: the list above says which of them run correctly, with what to write instead, and what was measured against 0.2.2. Three shapes 0.2.2 stated as open are refused now: a method wrapper with the method's own kinds over a keyword-only parameter with a default, whose body drops the object; the same over a method whose parameters are all keyword-only; and a wrapper a functools.partial binds under a functools.wraps of the function. Every judged default is written into the call, a None too, which closes a gap 0.2.2 had and did not state (a decorator that holds a second wrapper with another default for a parameter whose own default is None: judged {query: "q", region: None}, it ran region="eu" under 0.2.2, and runs None now), and which changes what a call that leaves a None default out does, in three cases (above). One limit is stated that 0.2.2 had and did not state (under Open: a held class-based wrapper with a staticmethod __call__ over a plain function).

Help make it better. Read the code, test this adapter against your own stack and tell us what you find. Reviews, bug reports and pull requests are all welcome: how to contribute, open issues. Please report a security gap privately, not in a public issue.

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.2.3

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.2.3
File Size Uploaded Provenance Actions
recusal_google_adk-0.2.3.tar.gz 49.9 kB With provenance Details for recusal_google_adk-0.2.3.tar.gz

Built distribution (wheel)

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

Total release size: 85.5 kB

Release files / recusal_google_adk-0.2.3.tar.gz

Download URL recusal_google_adk-0.2.3.tar.gz
Size 49.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7356fdf66b5db75503e329982661ab1f813816412099174fc5021e82309cf2bc
BLAKE2b-256 checksum
How to use checksums
2fa09375d8a48b00d4a00d4f525d1942f419d8e2f6cb1f235779fb37aae3fb01
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 30, 2026.

Transparency log

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

Download URL recusal_google_adk-0.2.3-py3-none-any.whl
Size 35.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c17a28980011781c7333b35ef3726d3f42a8752d1fcd032401b96bbba16cfc4
BLAKE2b-256 checksum
How to use checksums
8d9fbb3ca1111f4e097631ea7232250eaf22b52e739fee2c940214f6227d2004
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 30, 2026.

Transparency log

Security for recusal-google-adk 0.2.3

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.2.3.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 30, 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