Skip to content

Gemma 4 not registered in LLMRegistry — Gemma.supported_models() only matches gemma-3.* #5156

Closed

Description

@epicwhale

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:

  1. pip install google-adk>=1.28.1
  2. Set GOOGLE_API_KEY env var
  3. 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())

Activity

  1. added
    models[Component] This issue is related to model support
    on Apr 4, 2026
  2. added theissue type on Apr 4, 2026
  3. sanketpatil06 commented on Apr 7, 2026

    @sanketpatil06

    Hi @epicwhale, thank you for the detailed report. We have tested this on our end and can confirm the ValueError that occurs when attempting to resolve the Gemma 4 string through the LLMRegistry.

    Your suggested workaround is exactly right. Passing Gemini(model="gemma-4-31b-it") directly into the Agent is the best way to bypass the issue for now. Thank you for sharing this.

    Additionally, another community member, @pandego, has already opened a pull request (#5158) to update the regex pattern in Gemma.supported_models() to properly support the Gemma 4 family. The team is currently reviewing it.
    Thank you.

  4. self-assigned this
    on Apr 10, 2026
  5. added a commit that references this issue on Apr 10, 2026
    9d4ecbe
  6. added a commit that references this issue on Apr 21, 2026
    651b9bf
  7. added a commit that references this issue on Aug 11, 2026
    a53dd3f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

models[Component] This issue is related to model support

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions