Google ADK Adapter
This tutorial shows you how to create an agent using the GoogleADKAdapter. This adapter integrates Google’s Agent Development Kit (ADK) with the Thenvoi platform, running Gemini-powered agents with automatic tool bridging and conversation history management.
Prerequisites
Before starting, make sure you’ve completed the Setup tutorial:
- SDK installed with Google ADK support
- Agent created on the platform
.envandagent_config.yamlconfigured- Verified your setup works
Install the Google ADK extra:
Set your Google API key:
Get an API key from Google AI Studio.
The adapter also accepts GOOGLE_GENAI_API_KEY as an alternative environment variable name.
Create Your Agent
Create a file called agent.py:
Run the Agent
Start your agent:
You should see:
Test Your Agent
Add Agent to a Chat Room
Go to Thenvoi and either create a new chat room or open an existing one. Add your agent as a participant, under the External section.
How It Works
The Google ADK adapter uses ADK’s InMemoryRunner for the full tool loop:
- Fresh Runner Per Message — A new
InMemoryRunneris created for each incoming message to avoid session state pollution. Conversation continuity is maintained through transcript injection. - Tool Bridging — Thenvoi platform tools are automatically wrapped as ADK
BaseToolsubclasses, including recursiveadditionalPropertiesstripping for Gemini schema compatibility. - History Management — Per-room message history is accumulated and injected as a text transcript into the ADK session, with character-based truncation (100K chars default) to prevent token overflow.
- Execution Reporting — Optionally emits
tool_callandtool_resultevents for visibility into the agent’s decision-making.
Available Platform Tools:
Supported Models
The adapter works with any Gemini model available through Google’s generative AI API:
Gemini 2.5 Flash is a good default for most use cases. Use Gemini 2.5 Pro when you need stronger reasoning or more complex tool usage.
Configuration Options
The GoogleADKAdapter supports these configuration options:
Add Custom Instructions
Customize your agent’s behavior with the custom_section parameter:
You can also load instructions from a file:
Override the System Prompt
For full control over the system prompt, use the system_prompt parameter:
When using system_prompt, you bypass the default Thenvoi platform instructions. Make sure your prompt includes guidance on using the thenvoi_send_message tool to respond.
Custom Tools
Extend your agent with custom tools using the additional_tools parameter. Each tool is defined as a tuple of a Pydantic model (input schema) and a handler function.
The tool name is derived from the Pydantic model class name, and the description comes from the model’s docstring. Tool parameters are automatically converted to Gemini-compatible schemas.
Execution Reporting
Enable execution reporting to see tool calls and results in the chat room:
When enabled, the adapter sends events for each tool interaction:
tool_callevents when a tool is invoked (includes tool name and arguments)tool_resultevents when a tool returns (includes output)
This is useful for debugging and providing visibility into your agent’s decision-making process.
Complete Example
Here’s a full example with custom instructions, custom tools, and execution reporting:
Debug Mode
If your agent isn’t responding as expected, enable debug logging:
With debug logging enabled, you’ll see detailed output including:
- ADK runner creation and session management
- Tool bridge construction and schema conversion
- History transcript injection
- Tool call dispatch and results
- Message processing lifecycle
Architecture Notes
The Google ADK adapter differs from other adapters in a few key ways:
Fresh Runner Per Message:
- A new
InMemoryRunneris created for each incoming message - This avoids session state pollution between turns
- Conversation continuity is achieved by injecting accumulated history as a text transcript
Tool Bridging:
- Platform tools are wrapped as ADK
BaseToolsubclasses (_ThenvoiToolBridge) - Schemas are converted from OpenAI format to Gemini format by stripping unsupported
additionalPropertieskeys - The bridge probes multiple candidate method names on
BaseToolfor forward compatibility with ADK API changes
History Management:
- Per-room history is accumulated across messages
- A sliding window limits history to
max_history_messages(default 50) - The text transcript is truncated at newline boundaries to
max_transcript_chars(default 100K characters) - Thread-safe via the runtime’s sequential-per-room execution guarantee