Skip to Content
These docs describe donkey-kit v0.2.1. Release notes
ExamplesGoogle ADK

Offline-verified

Google ADK

Google ADK with donkey.adk.model("…"), a LiteLlm model. LiteLLM calls the proxy’s /chat/completions route. It sends through the SDK’s shared HTTP client, so the credentials and the run id go on the wire. LiteLLM raises its own errors, so a refusal becomes a typed error only inside donkey.run() or @donkey.governed. Script 02 calls the agent outside them, so it shows LiteLLM’s own error.

Both scripts need a live gateway; there is no offline ADK script.

#ScriptShowsNeeds
01basic-gw.pyAn ADK Agent through an InMemoryRunnerProxy credentials
02refusal-live.pyA PII refusal surfacing as LiteLLM’s APIErrorProxy + PII policy

Install

Follow the examples setup first, then:

python -m pip install -e "../donkey-development-kit/python[llm,adk]" set -a; source .env.local; set +a

01 — An ADK agent

python "demos/human-made/adk/01 - basic-gw.py"
donkey = Donkey.from_env() agent = Agent(name="greeter", model=donkey.adk.model("gpt-4o"), instruction="Answer in one short sentence.") events = asyncio.run(InMemoryRunner(agent=agent).run_debug("Say hello in exactly three words.", quiet=True)) print(events[-1].content.parts[0].text) print("total tokens", events[-1].usage_metadata.total_token_count) print("last_call ", donkey.last_call.status.value, donkey.last_call.surface)

You should see: a one-sentence answer, total tokens from the last event’s usage_metadata, and last_call unobserved …. The record is set in the Runner’s own task, not where the script reads it, so the script’s read is a cold one. Read it in an after_model_callback instead, as shown under Native Gemini. LiteLLM also logs a provider-list banner, which is harmless.

02 — A refusal outside donkey.run()

python "demos/human-made/adk/02 - refusal-live.py"

A PII prompt against a proxy with the PII policy applied. LiteLLM keeps the status code and the message but drops the response headers, so classify() has nothing to read. The script makes the call outside donkey.run(), so it catches LiteLLM’s own error:

try: asyncio.run(InMemoryRunner(agent=agent).run_debug(PII_PROMPT, quiet=True)) print("NO REFUSAL") except litellm.exceptions.APIError as err: print(type(err).__name__, err.status_code) print(str(err).splitlines()[0])

Needs: llm-pii-detection-policy with Email and action Reject. You should see: APIError 403 and the first line of the proxy’s message — not PIIDetected. Without the policy it prints NO REFUSAL.

Wrap the same call in donkey.run() and the refusal reaches your code as PIIDetected, with LiteLLM’s APIError on framework_error:

async def main(): async with donkey.run(): await InMemoryRunner(agent=agent).run_debug(PII_PROMPT, quiet=True) try: asyncio.run(main()) except PIIDetected as err: print(type(err).__name__, type(err.framework_error).__name__)

Typed refusals on model() need the LiteLlm that donkey.adk.model() returns. One you build from connection_kwargs() raises LiteLLM’s errors even inside donkey.run() (see Google ADK). A 404 here means the proxy’s upstream has no /chat/completions route.

Learn more: Google ADK

Source: demos/human-made/adk/

Last updated on