1. Environment Setup & Troubleshooting
First, I signed up for the Groq console at console.groq.com/home and generated an API key at console.groq.com/keys.
I used Python 3.13 to create the virtual environment:
python3.13 -m venv .venv
The Dependencies & Downgrade Workaround
Initially, I planned to run a standard install, but I ran into a LiteLLM serialization issue. To bypass this, I had to downgrade google-adk to the 1.28.0 range and include python-dotenv:
pip3.13 install "google-adk~=1.28.0" litellm python-dotenv
Updated Project Structure (ls -R)
.
├── requirements.txt
└── time_agent/
├── __init__.py
└── agent.py
Inside the .env file, I added the Groq API key:
GROQ_API_KEY="your_api_key_here"
2. Resolving the Groq Request Error
During implementation, I hit a Groq request error regarding reasoning/thought blocks. I added this custom callback to strip out reasoning content from the LLM request parts before it hits the model:
def strip_reasoning_content(callback_context, llm_request):
for content in llm_request.contents:
if content.parts:
content.parts = [
p for p in content.parts if not (hasattr(p, "thought") and p.thought)
]
return None
3. The Complete Code (time_agent/agent.py)
Here is the complete source integrating the tool mapping, the custom callback, and the Groq LLM configuration.
import datetime
import zoneinfo
from google.adk.agents import LlmAgent
from google.adk.models.lite_llm import LiteLlm
def strip_reasoning_content(callback_context, llm_request):
for content in llm_request.contents:
if content.parts:
content.parts = [
p for p in content.parts if not (hasattr(p, "thought") and p.thought)
]
return None
def get_current_time(timezone):
tz = zoneinfo.ZoneInfo(timezone)
now = datetime.datetime.now(tz)
return f"Current time in {timezone}: {now.strftime('%I:%M %p on %A, %B %d, %Y')}"
root_agent = LlmAgent(
model=LiteLlm(model="groq/openai/gpt-oss-20b"),
name="groq_time_assistant",
description="An assistant powered by Groq that can tell the current time",
instruction=(
"You are a helpful assistant. When the user asks about the current time "
"in any location, use the get_current_time tool with the appropriate "
"IANA timezone name (e.g. 'US/Eastern', 'Asia/Kolkata', 'Europe/Paris'). "
"If the user gives a city name, map it to the correct timezone yourself."
),
tools=[get_current_time],
before_model_callback=strip_reasoning_content,
)
4. Execution & Testing
I ran adk web to spin up the web UI and test the code locally.
Backend Logs
The console confirmed LiteLLM completion calls successfully routing through Groq:
13:56:26 - LiteLLM:INFO: utils.py:4054 - LiteLLM completion() model= openai/gpt-oss-20b; provider = groq
2026-05-31 13:56:26,332 - INFO - utils.py:4054 - LiteLLM completion() model= openai/gpt-oss-20b; provider = groq
Web UI Behavior
When tested with the query “what’s the current time in tokyo ?”, the agent successfully mapped the city to the correct timezone, called the tool, and outputted the final time.
- Thought:
Need to map Tokyo to timezone: Asia/Tokyo. Then call get_current_time. - Tool Call:
get_current_time - Output:
Sure! The current time in Tokyo (Asia/Tokyo) is 05:26 PM on Sunday, May 31, 2026.
Metrics
Checking the Groq Console dashboard after the test runs showed a clean and efficient footprint with total token usage sitting at 2.1K tokens.