-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Gemma 4 not registered in LLMRegistry — Gemma.supported_models() only matches gemma-3.* #5156
Copy link
Copy link
Labels
models[Component] Issues related to model support[Component] Issues related to model support
Description
Using model="gemma-4-31b-it" (string) in an ADK Agent raises:
ValueError: Model gemma-4-31b-it not found.
Gemma.supported_models() returns [r'gemma-3.*'], so the registry never
routes Gemma 4 model strings to the Gemma class.
Workaround: Using Gemini(model="gemma-4-31b-it") as the model value
bypasses the registry and works correctly — including tool calling with
thinking parts. This confirms the underlying API support is fine; only the
registry pattern is missing.
Suggested fix: Update the regex in Gemma.supported_models() to
r'gemma-.*' (or add r'gemma-4.*').
Versions: google-adk 1.28.1, Python 3.14
Steps to reproduce:
- pip install google-adk>=1.28.1
- Set GOOGLE_API_KEY env var
- Run this file: python gemma4_bug_repro.py
import asyncio
from dotenv import load_dotenv
load_dotenv(".env")
from google.adk.agents import Agent
from google.adk.models.google_llm import Gemini
from google.adk.models.gemma_llm import Gemma
from google.adk.models.registry import LLMRegistry
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.genai import types
import datetime
def get_current_time() -> dict:
"""Returns the current date and time."""
now = datetime.datetime.now()
return {
"date": now.strftime("%Y-%m-%d"),
"time": now.strftime("%H:%M:%S"),
}
# ---------------------------------------------------------------------------
# BUG: Registry does not recognize gemma-4-* as a string
# ---------------------------------------------------------------------------
def demo_registry_miss():
print("=" * 70)
print("BUG: model='gemma-4-31b-it' (string) — not found in registry")
print("=" * 70)
LLMRegistry.resolve.cache_clear()
try:
LLMRegistry.resolve("gemma-4-31b-it")
print("PASS — model resolved (unexpected on ADK 1.28.1)\n")
except ValueError as e:
print(f"FAIL — {e}\n")
# ---------------------------------------------------------------------------
# WORKAROUND: Gemini(model=...) bypasses the registry and works fine
# ---------------------------------------------------------------------------
async def demo_gemini_workaround():
print("=" * 70)
print("WORKAROUND: model=Gemini(model='gemma-4-31b-it') — works")
print("=" * 70)
agent = Agent(
model=Gemini(model="gemma-4-31b-it"),
name="test_agent",
description="A test agent.",
instruction="Use get_current_time when the user asks for the time.",
tools=[get_current_time],
)
svc = InMemorySessionService()
await svc.create_session(app_name="repro", user_id="u1", session_id="s1")
runner = Runner(agent=agent, app_name="repro", session_service=svc)
msg = types.Content(
role="user",
parts=[types.Part.from_text(text="What is the current time?")],
)
tool_was_called = False
final_text = ""
async for event in runner.run_async(
user_id="u1", session_id="s1", new_message=msg
):
if event.content and event.content.parts:
for part in event.content.parts:
if part.function_call:
tool_was_called = True
print(f" tool_call: {part.function_call.name}({part.function_call.args})")
if part.function_response:
print(f" tool_response: {part.function_response.response}")
if part.text and not getattr(part, "thought", False):
final_text = part.text
if tool_was_called:
print(f" PASS — tool called, response: {final_text!r}\n")
else:
print(f" FAIL — tool was NOT called, response: {final_text!r}\n")
# ---------------------------------------------------------------------------
# Run
# ---------------------------------------------------------------------------
if __name__ == "__main__":
demo_registry_miss()
asyncio.run(demo_gemini_workaround())
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
models[Component] Issues related to model support[Component] Issues related to model support