fix(agent): disable reasoning on the title-generation pass
This commit is contained in:
@@ -267,6 +267,13 @@ def generate_title(
|
||||
# A title is a handful of tokens; a larger ceiling let chatty models burn seconds.
|
||||
max_tokens=64, temperature=0.3, timeout=timeout, main_runtime=main_runtime,
|
||||
extra_body={"response_format": _TITLE_RESPONSE_FORMAT},
|
||||
# The module contract above promises thinking-disabled operation,
|
||||
# but nothing enforced it: with the aux default reasoning_effort
|
||||
# "" (provider default), Gemini enables internal thinking and
|
||||
# bills thought tokens against max_tokens=64 — the JSON payload
|
||||
# never lands, and the prose fallback stores the opening fence
|
||||
# ("```json") as the session title (#91927).
|
||||
reasoning_config={"enabled": False},
|
||||
)
|
||||
title = _clean_title(_extract_title_text(response.choices[0].message.content or ""))
|
||||
# Answer-shaped output guard: titling is a 3-7 word task, so a title with many words is a model that
|
||||
|
||||
@@ -46,6 +46,29 @@ class TestGenerateTitle:
|
||||
assert captured_kwargs["task"] == "title_generation"
|
||||
assert captured_kwargs["timeout"] is None
|
||||
|
||||
def test_generate_title_disables_reasoning(self):
|
||||
"""The titling pass must explicitly disable thinking (#91927).
|
||||
|
||||
With the aux default reasoning_effort "" (provider default), Gemini
|
||||
bills internal thought tokens against max_tokens=64, the JSON payload
|
||||
never lands, and the prose fallback stores the opening fence
|
||||
("```json") as the title. Enforce the module's documented
|
||||
thinking-disabled contract at the call site.
|
||||
"""
|
||||
captured_kwargs = {}
|
||||
|
||||
def mock_call_llm(**kwargs):
|
||||
captured_kwargs.update(kwargs)
|
||||
resp = MagicMock()
|
||||
resp.choices = [MagicMock()]
|
||||
resp.choices[0].message.content = '{"title": "Reasoning Off"}'
|
||||
return resp
|
||||
|
||||
with patch("agent.title_generator.call_llm", side_effect=mock_call_llm):
|
||||
assert generate_title("question") == "Reasoning Off"
|
||||
|
||||
assert captured_kwargs.get("reasoning_config") == {"enabled": False}
|
||||
|
||||
|
||||
|
||||
def test_strips_think_blocks(self):
|
||||
|
||||
Reference in New Issue
Block a user