diff --git a/lm15/providers/gemini.py b/lm15/providers/gemini.py index adf520e..d1f676f 100644 --- a/lm15/providers/gemini.py +++ b/lm15/providers/gemini.py @@ -123,14 +123,14 @@ } def gemini_level_class(model: str) -> bool: - """True for the Gemini 3.x class: `thinkingLevel`, no full off (MAP-7 rule 10). + """True for the Gemini 3.x/4.x class: `thinkingLevel`, no full off (MAP-7 rule 10). Model-name table, receipted 2026-09-02: 2.5 models reject thinkingLevel, 3.x models take it; 3.7 Flash accepts thinkingBudget: 0 and still spends - thinking tokens. A table that rots; `extensions` overrides. + thinking tokens. 4.x (2026-11-20, Vertex): thinkingBudget is a 400. + A table that rots; `extensions` overrides. """ - lowered = model.lower() - return lowered.startswith("models/gemini-3") or lowered.startswith("gemini-3") + return model.lower().removeprefix("models/").startswith(("gemini-3", "gemini-4")) diff --git a/tests/test_reasoning_mapping.py b/tests/test_reasoning_mapping.py index 1aeef65..87667d4 100644 --- a/tests/test_reasoning_mapping.py +++ b/tests/test_reasoning_mapping.py @@ -35,6 +35,7 @@ def test_model_class_tables() -> None: assert anthropic_adaptive_class("claude-sonnet-5") and anthropic_adaptive_class("claude-opus-4-8") and anthropic_adaptive_class("claude-fable-5-1") assert not anthropic_adaptive_class("claude-sonnet-4-5-20250929") and not anthropic_adaptive_class("claude-haiku-4-5-20251001") assert gemini_level_class("gemini-3.7-flash") and gemini_level_class("models/gemini-3.1-pro-preview") + assert gemini_level_class("gemini-4-neon") and gemini_level_class("models/gemini-4-carbon") assert not gemini_level_class("gemini-2.5-flash") assert EFFORT_THINKING_BUDGETS == {"minimal": 1024, "low": 2048, "medium": 8192, "high": 16384, "xhigh": 24576, "max": 32768} @@ -148,6 +149,7 @@ def test_gemini_two_classes() -> None: assert tc("gemini-2.5-flash", Reasoning(effort="off")) == {"thinkingBudget": 0} assert tc("gemini-3.7-flash", Reasoning(effort="medium", summary="auto")) == {"includeThoughts": True, "thinkingLevel": "medium"} assert tc("gemini-3.7-flash", Reasoning(effort="medium", thinking_budget=512)) == {"thinkingBudget": 512} + assert tc("gemini-4-neon", Reasoning(effort="medium")) == {"thinkingLevel": "medium"} # MAP-13: above the ceiling clamps to "high"; off on the 3 class (no honoured # off switch) substitutes the lowest level — both recorded. for eff in ("xhigh", "max"):