Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion agent/title_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
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]:
Expand All @@ -43,6 +43,10 @@ def generate_title(
auxiliary call raises β€” the caller typically wires this to
``AIAgent._emit_auxiliary_failure`` so the user sees a warning instead
of silently accumulating untitled sessions.

``timeout`` defaults to ``None``, which makes ``call_llm()`` resolve it
from ``auxiliary.title_generation.timeout`` in config.yaml (falling
back to 30 s). Pass a float to override programmatically.
"""
# Truncate long messages to keep the request small
user_snippet = user_message[:500] if user_message else ""
Expand Down
16 changes: 16 additions & 0 deletions tests/agent/test_title_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,22 @@ def mock_call_llm(**kwargs):
user_content = captured_kwargs["messages"][1]["content"]
assert len(user_content) < 1100 # 500 + 500 + formatting

def test_passes_timeout_none_when_not_specified(self):
"""When no timeout is given, None is passed so config resolution works."""
captured_kwargs = {}

def mock_call_llm(**kwargs):
captured_kwargs.update(kwargs)
resp = MagicMock()
resp.choices = [MagicMock()]
resp.choices[0].message.content = "Title"
return resp

with patch("agent.title_generator.call_llm", side_effect=mock_call_llm):
generate_title("q", "a")

assert captured_kwargs["timeout"] is None


class TestAutoTitleSession:
"""Tests for auto_title_session() β€” the sync worker function."""
Expand Down