Google ADK

How to use Call4Agents with Google ADK: where the run id comes from and what to wrap.

Call4Agents makes an ADK tool act at most once per session, tool and exact arguments, and can bind ADK's tool confirmation to the exact arguments the person saw.

Install

pip install call4agents google-adk

Tested with google-adk 2.14.0 (the newest release on 12 November 2026), Python 3.12.

Example

import call4agents as c4a
from call4agents.adapters import google_adk as c4a_adk
from google.adk.agents import LlmAgent
from google.adk.tools import ToolContext

c4a.init()                                   # the run record: ./.c4a/ledger.sqlite

@c4a_adk.effect                              # once per session, tool and exact arguments
def send_email(to: str, body: str, tool_context: ToolContext) -> str:
    """Send an email."""
    ...

agent = LlmAgent(name="mailer", model=..., tools=[send_email])

A runnable version with a scripted model (no API key, no network): python -m call4agents.examples.google_adk_tool. It sends the same message twice in one session: 2 emails without the kit, 1 with it.

Where the run id comes from

From the ADK session in the tool context: app name, user id and session id together (c4a_adk.run_id(session) shows it). We use the session, not the invocation id:

The cost: in one session, the same tool with the same arguments acts once. For a deliberate second identical action, pass c4a_key="..." at call time.

The tool context is left out of the key. The adapter finds it the way ADK does (a parameter typed as ToolContext / Context, or named tool_context), so a model argument named context stays in the key. An active with c4a.run(...) wins over the session. A tool with no context parameter needs with c4a.run(...) around the run, or it stops with a clear error.

Tool confirmation

from google.adk.tools import FunctionTool

guarded = c4a_adk.effect(approval=True)(send_email)
tool = FunctionTool(guarded, require_confirmation=True)

# ADK asks with an adk_request_confirmation function call; show its arguments to the person, then:
answer = c4a_adk.confirm(call, True, tools=[tool], session=session)   # or False for a no
runner.run_async(user_id=..., session_id=..., new_message=answer)

confirm() records c4a.approve (or c4a.deny) for exactly the arguments in the confirmation call, then returns the answer for ADK. When the tool runs, Call4Agents checks the yes against the arguments it really runs with. It refuses a tool not wrapped with approval=True, because the yes would then bind nothing.

What is tested

python -m tests.test_adapters_more2 --require-frameworks (real ADK, scripted model, offline; a socket guard fails the run on any non-loopback connection):

Each check is mutation-proven (python -m tests.mutations.run_kit_mutations --adapters-more2).

Known limits

Source: docs/frameworks/google_adk.md in the repository.