fix(llm): forward reasoning effort to GPT-6 and gate minimal thinking

- reasoning_effort was forwarded only to IDs matching gpt-5 or the o-series, so
  GPT-6 models silently dropped the configured effort; match GPT-5 and later,
  with a version boundary so unrelated IDs do not match
- Gemini Pro, 3.8+ and the -latest aliases reject thinking_level "minimal"
  with a 400; send it only to numbered Flash models before 3.8 and map it to
  "low" elsewhere, since aliases move between generations
This commit is contained in:
Yijia-Xiao
2026-09-14 18:09:33 +00:00
parent 62d3479217
commit 9b4c741d33
4 changed files with 42 additions and 11 deletions

View File

@@ -1,8 +1,8 @@
"""Gemini thinking_level forwarding (Gemini 3.x).
The catalog is Gemini 3.x only, which takes the string ``thinking_level``
directly. Pro accepts low/high; Flash also accepts minimal/medium — an
unsupported "minimal" on Pro is mapped to "low".
directly. Pro, Gemini 3.8+ and the -latest aliases reject "minimal" with a 400,
so it is mapped to "low" there; numbered Flash models before 3.8 accept it.
"""
from unittest import mock
@@ -35,6 +35,22 @@ def test_pro_remaps_minimal_to_low():
assert kw["thinking_level"] == "low" # Pro doesn't accept "minimal"
def test_flash_38_remaps_minimal_to_low():
kw = _captured_kwargs("gemini-3.8-flash", thinking_level="minimal")
assert kw["thinking_level"] == "low" # 3.8 Flash 400s on "minimal"
def test_flash_38_keeps_supported_levels():
kw = _captured_kwargs("gemini-3.8-flash", thinking_level="high")
assert kw["thinking_level"] == "high"
@pytest.mark.parametrize("alias", ["gemini-flash-latest", "gemini-pro-latest"])
def test_latest_alias_remaps_minimal_to_low(alias):
# Aliases move between generations; gemini-flash-latest 400s on "minimal".
assert _captured_kwargs(alias, thinking_level="minimal")["thinking_level"] == "low"
def test_pro_keeps_high():
kw = _captured_kwargs("gemini-3.1-pro-preview", thinking_level="high")
assert kw["thinking_level"] == "high"