fix(title-gen): surface auxiliary failures via _emit_auxiliary_failure

Closes #15775.

Title generation swallowed exceptions at debug level and returned None,
so a depleted auxiliary provider (e.g. OpenRouter 402) silently left
sessions with NULL titles. Reporter observed 45 untitled sessions
accumulated over 19 days with no user-visible indication.

- agent/title_generator.py: accept optional failure_callback, bump log
  to WARNING, invoke callback on call_llm exception (swallowing callback
  errors so nothing can crash the fire-and-forget worker thread).
- cli.py, gateway/run.py: pass agent._emit_auxiliary_failure as the
  callback so failures route through the existing user-visible warning
  channel.
- tests: cover callback fires / errors are swallowed / no-callback
  legacy behavior / maybe_auto_title forwards kwarg to worker.
This commit is contained in:
Teknium 2026-04-26 21:48:15 -07:00 committed by Teknium
parent bda2dbc29e
commit 4a2ee6c162
4 changed files with 103 additions and 5 deletions

8
cli.py
View file

@ -8672,12 +8672,20 @@ class HermesCLI:
if response and result and not result.get("failed") and not result.get("partial"):
try:
from agent.title_generator import maybe_auto_title
# Route title-generation failures through the agent's
# user-visible warning channel so a depleted auxiliary
# provider doesn't silently leave sessions untitled
# (issue #15775).
_title_failure_cb = getattr(
self.agent, "_emit_auxiliary_failure", None
) if self.agent else None
maybe_auto_title(
self._session_db,
self.session_id,
message,
response,
self.conversation_history,
failure_callback=_title_failure_cb,
)
except Exception:
pass