This commit is contained in:
Sun Zhigang 2026-09-12 23:59:41 -07:00 committed by GitHub
commit 3953d5b834
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 3 deletions

View file

@ -878,9 +878,12 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):
# Covers gemini-3-flash, gemini-3-flash-preview, gemini-3.1-flash, gemini-3.1-flash-lite-preview,
# gemini-3.5-flash, and any future 3.x-flash variants.
is_gemini3flash: Final = model and ("flash" in model.lower() and "gemini-3" in model.lower())
requires_low_minimum_thinking: Final = model and (
"gemini-3.7-flash" in model.lower() or "gemini-3.8-flash" in model.lower()
)
is_gemini31pro: Final = model and ("gemini-3.1-pro-preview" in model.lower())
if reasoning_effort == "minimal":
if is_gemini3flash:
if is_gemini3flash and not requires_low_minimum_thinking:
return {"thinkingLevel": "minimal", "includeThoughts": True}
else:
return {"thinkingLevel": "low", "includeThoughts": True}
@ -895,13 +898,13 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):
return {"thinkingLevel": "high", "includeThoughts": True}
elif reasoning_effort == "disable":
# Gemini 3 cannot fully disable thinking, so we use "minimal" for gemini-3-flash-preview, "low" for others
if is_gemini3flash:
if is_gemini3flash and not requires_low_minimum_thinking:
return {"thinkingLevel": "minimal", "includeThoughts": False}
else:
return {"thinkingLevel": "low", "includeThoughts": False}
elif reasoning_effort == "none":
# For gemini-3-flash-preview, use "minimal" instead of "low"
if is_gemini3flash:
if is_gemini3flash and not requires_low_minimum_thinking:
return {"thinkingLevel": "minimal", "includeThoughts": False}
else:
return {"thinkingLevel": "low", "includeThoughts": False}

View file

@ -2678,6 +2678,20 @@ def test_reasoning_effort_maps_to_thinking_level_gemini_3():
assert result["thinkingConfig"]["includeThoughts"] is False
@pytest.mark.parametrize("model", ["vertex_ai/gemini-3.7-flash", "vertex_ai/gemini-3.8-flash"])
@pytest.mark.parametrize("reasoning_effort", ["minimal", "disable", "none"])
def test_gemini_flash_uses_low_minimum_thinking_level(model: str, reasoning_effort: str):
result = VertexGeminiConfig().map_openai_params(
non_default_params={"reasoning_effort": reasoning_effort},
optional_params={},
model=model,
drop_params=False,
)
assert result["thinkingConfig"]["thinkingLevel"] == "low"
assert result["thinkingConfig"]["includeThoughts"] is (reasoning_effort == "minimal")
def test_reasoning_effort_dict_format_gemini_3():
"""
Test that reasoning_effort works when passed as dict format from OpenAI Agents SDK.