From 5126902f1d77ccca0fb7b0f9c780d9b80e6a4fe2 Mon Sep 17 00:00:00 2001 From: shandian64 <22763347+shandian64@users.noreply.github.com> Date: Mon, 8 Jun 2026 13:57:47 +0800 Subject: [PATCH] fix(title): honor configured auxiliary timeout --- agent/title_generator.py | 2 +- tests/agent/test_title_generator.py | 31 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/agent/title_generator.py b/agent/title_generator.py index 583a2cfc601..c7ce2375fc9 100644 --- a/agent/title_generator.py +++ b/agent/title_generator.py @@ -51,7 +51,7 @@ def _title_language() -> str: def generate_title( user_message: str, assistant_response: str, - timeout: float = 30.0, + timeout: Optional[float] = None, failure_callback: Optional[FailureCallback] = None, main_runtime: dict = None, ) -> Optional[str]: diff --git a/tests/agent/test_title_generator.py b/tests/agent/test_title_generator.py index 43b1c1e6bf9..bda0f0caf02 100644 --- a/tests/agent/test_title_generator.py +++ b/tests/agent/test_title_generator.py @@ -59,6 +59,37 @@ class TestGenerateTitle: with patch("hermes_cli.config.load_config", side_effect=RuntimeError("bad config")): assert _title_language() == "" + def test_default_timeout_delegates_to_auxiliary_config(self): + captured_kwargs = {} + + def mock_call_llm(**kwargs): + captured_kwargs.update(kwargs) + resp = MagicMock() + resp.choices = [MagicMock()] + resp.choices[0].message.content = "Configured Timeout" + return resp + + with patch("agent.title_generator.call_llm", side_effect=mock_call_llm): + assert generate_title("question", "answer") == "Configured Timeout" + + assert captured_kwargs["task"] == "title_generation" + assert captured_kwargs["timeout"] is None + + def test_explicit_timeout_still_overrides_config(self): + captured_kwargs = {} + + def mock_call_llm(**kwargs): + captured_kwargs.update(kwargs) + resp = MagicMock() + resp.choices = [MagicMock()] + resp.choices[0].message.content = "Explicit Timeout" + return resp + + with patch("agent.title_generator.call_llm", side_effect=mock_call_llm): + assert generate_title("question", "answer", timeout=123.0) == "Explicit Timeout" + + assert captured_kwargs["timeout"] == 123.0 + def test_strips_quotes(self): mock_response = MagicMock() mock_response.choices = [MagicMock()]