Skip to content

Commit e5fa990

Browse files
google-genai-botcopybara-github
authored andcommitted
chore: Checks gemini EAP models for gemini-builtin tools
PiperOrigin-RevId: 910941961
1 parent 01f1fc9 commit e5fa990

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

src/google/adk/tools/url_context_tool.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
from ..utils.model_name_utils import is_gemini_1_model
2323
from ..utils.model_name_utils import is_gemini_2_or_above
24+
from ..utils.model_name_utils import is_gemini_eap_model
2425
from ..utils.model_name_utils import is_gemini_model_id_check_disabled
2526
from .base_tool import BaseTool
2627
from .tool_context import ToolContext
@@ -52,7 +53,11 @@ async def process_llm_request(
5253
llm_request.config.tools = llm_request.config.tools or []
5354
if is_gemini_1_model(llm_request.model):
5455
raise ValueError('Url context tool cannot be used in Gemini 1.x.')
55-
elif is_gemini_2_or_above(llm_request.model) or model_check_disabled:
56+
elif (
57+
is_gemini_2_or_above(llm_request.model)
58+
or is_gemini_eap_model(llm_request.model)
59+
or model_check_disabled
60+
):
5661
llm_request.config.tools.append(
5762
types.Tool(url_context=types.UrlContext())
5863
)

src/google/adk/utils/model_name_utils.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,31 @@ def is_gemini_2_or_above(model_string: Optional[str]) -> bool:
127127
return parsed_version.major >= 2
128128

129129

130+
def is_gemini_eap_model(model_string: Optional[str]) -> bool:
131+
"""Check if the model is an Early Access Program (EAP) Gemini model.
132+
133+
Matches names of the form ``gemini-<variant>-early-exp`` optionally
134+
followed by a numeric suffix, e.g. ``gemini-flash-early-exp`` or
135+
``gemini-flash-early-exp3``. ``<variant>`` is one or more
136+
alphanumeric/underscore segments separated by ``-`` (e.g. ``flash``,
137+
``pro``, ``flash-lite``).
138+
139+
Args:
140+
model_string: Either a simple model name or path-based model name.
141+
142+
Returns:
143+
True if it matches the EAP naming convention, False otherwise.
144+
"""
145+
if not model_string:
146+
return False
147+
148+
model_name = extract_model_name(model_string)
149+
return (
150+
re.match(r'^gemini-[a-z0-9_]+(?:-[a-z0-9_]+)*-early-exp\d*$', model_name)
151+
is not None
152+
)
153+
154+
130155
def is_gemini_3_1_flash_live(model_string: Optional[str]) -> bool:
131156
"""Check if the model is a Gemini 3.1 Flash Live model.
132157

0 commit comments

Comments
 (0)