Mandate · Guide
Gate Google ADK tools
Use provenanceauth-google-adk to add approvals to an agent built with Google's Agent Development Kit (ADK). Its before_tool_callback authorizes and verifies each listed tool call on its exact arguments before the tool runs, and waits for a person when your policy asks for one.
Before you begin: install the package, and export the sandbox account key.
export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
This package isn't on PyPI yet. Until then, every request in these docs runs over HTTP against the sandbox.
With access to the private Provenance repository, which your Provenance contact grants, install from it:
git clone https://github.com/michaelnbane-jpg/provenance.git provenance
pip install ./provenance/python/sdk ./provenance/python/google-adk-provenanceAvailability: the package is available to beta customers. It supports google-adk 1.20 to 2.x.
1. Add the callback
provenance_before_tool returns a before_tool_callback. List the tools to gate by name:
import os
from google.adk.agents import LlmAgent
from provenanceauth_google_adk import provenance_before_tool
from provenanceauth import Provenance
prov = Provenance(os.environ["PROVENANCE_KEY"], base_url=os.environ["PROVENANCE_API"])
def pay_invoice(invoice: str, amount: float, payee: str) -> dict:
"""Pay a supplier invoice."""
return {"status": "paid", "invoice": invoice}
agent = LlmAgent(
name="billing",
model="gemini-2.5-flash",
instruction="Pay supplier invoices.",
tools=[pay_invoice],
before_tool_callback=provenance_before_tool(
tools=["pay_invoice"],
client=prov,
device_id="dev_00000000000000000000000000000001",
),
)
Each call is bound to the ADK session id as the agent session. By default the action description is the tool name and the canonical JSON of its arguments, and the payload is { "tool", "input" }.
2. Read the outcome
| Outcome | What happens |
|---|---|
| Verified | The callback returns None, and the tool runs with the arguments that were verified |
| Denied | The callback returns {"status": "denied", "reason": …}, which ADK uses as the tool's result instead of running it |
| Waiting for approval | The callback waits for the person, up to timeout_ (default 2 minutes), then lets the tool run or denies it |
The reason is a sentence the model reads, such as "The person declined this action." If the person hasn't answered when the wait ends, it says "Waiting for approval (appr_…)", and the next call with the same arguments reuses the token that opened the approval. Tools you don't list run as usual.
3. Show the wait with tool confirmation
Pass confirmation=True to use ADK's tool confirmation as the waiting screen. When a call is still waiting, the callback asks the client to confirm, with a hint naming the approval. When the person's client confirms, ADK runs the callback again, and the tool runs only if Provenance now says the person approved:
before = provenance_before_tool(
tools=["pay_invoice"],
client=prov,
device_id="dev_00000000000000000000000000000001",
timeout_ms=0,
confirmation=True,
)
4. Pass the rest of the options
Pass a dict of tool name → options as tools to set the options below for one tool, or pass them to provenance_before_tool for every tool:
contextfunction- Facts for your policy, read at verify.
run_idstring- An agent-team run to bind each call to.
mandate_tokenstring- A grant to authorize under.
agent_idstring- The registered agent making the calls.
timeout_msnumber- How long to wait for the person.
0answers at once.
Errors you might see
| Symptom | Cause | Fix |
|---|---|---|
| A listed tool always runs | The name doesn't match the tool's name | Use the function's name, or a trailing * for a prefix. |
| The model reads "Waiting for approval" | The person hadn't answered within timeout_ | Raise timeout_, or turn on confirmation. |