Skip to content

The agent that grows with you

fix(agent): stop titling a session after our own scaffolding, or a TTS model

Brooklyn Nicholson53a4003208b4
diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py
index 0e3b83b5c6c..6ead8eff6aa 100644
--- a/agent/auxiliary_client.py
+++ b/agent/auxiliary_client.py
@@ -735,9 +735,13 @@ _FAST_MODEL_FAMILIES: tuple = (
# opposite of what a titler wants; ":batch" is an async queue, not a live
# endpoint; embedding models ("all-minilm") match "-mini" but aren't chat
# models at all; ":free" tiers are heavily rate-limited and measured slowest.
+# The modality suffixes are the same trap as the embedders — a provider names
+# its speech and image endpoints after the chat model they're paired with, so
+# "gpt-4o-mini-tts" satisfies the "-mini" rung and cannot answer a prompt.
_FAST_MODEL_EXCLUDE: tuple = (
"thinking", "reason", "-r1", "minilm", ":batch", ":free",
"o1-", "o3-", "o4-", "codex", "audio", "-vl", "embed",
+ "-tts", "-transcribe", "-realtime", "-image", "-search-preview",
)
diff --git a/agent/title_generator.py b/agent/title_generator.py
index ca664022efc..5f6635ce15e 100644
--- a/agent/title_generator.py
+++ b/agent/title_generator.py
@@ -24,6 +24,7 @@ import threading
from typing import Callable, Optional
from agent.auxiliary_client import call_llm
+from agent.context_compressor import LEGACY_SUMMARY_PREFIX
logger = logging.getLogger(__name__)
@@ -122,10 +123,14 @@ _CONTROL_WRAPPERS = (
)
# Hermes' own machine-authored openers. A compaction handoff or a resumed
-# session must not be titled after the scaffolding that carried it.
+# session must not be titled after the scaffolding that carried it. The legacy
+# summary prefix comes from the compressor rather than a fourth local copy —
+# compaction still emits it, and a session named after it is named after us.
_MACHINE_PREFIXES = (
"[CONTEXT COMPACTION",
+ LEGACY_SUMMARY_PREFIX,
"[Runtime note:",
+ "[System note:",
"[SYSTEM]",
)
diff --git a/tests/agent/test_auxiliary_client.py b/tests/agent/test_auxiliary_client.py
index dbbd012ea4c..803b69c98c0 100644
--- a/tests/agent/test_auxiliary_client.py
+++ b/tests/agent/test_auxiliary_client.py
@@ -4519,6 +4519,20 @@ class TestFastModelTier:
with patch("hermes_cli.models.fetch_models_with_pricing", return_value=catalog):
assert ac._fast_model_from_catalog("nous") == "google/gemini-3.6-flash"
+ def test_catalog_match_skips_the_non_chat_siblings_of_a_chat_model(self):
+ """A provider names its speech and image endpoints after the chat model
+ they're paired with, so they satisfy the family rungs and can't answer."""
+ from agent import auxiliary_client as ac
+
+ catalog = {
+ "openai/gpt-4o-mini-tts": {},
+ "openai/gpt-4o-mini-transcribe": {},
+ "openai/gpt-4o-mini-search-preview": {},
+ "openai/gpt-4o-mini": {},
+ }
+ with patch("hermes_cli.models.fetch_models_with_pricing", return_value=catalog):
+ assert ac._fast_model_from_catalog("nous") == "openai/gpt-4o-mini"
+
def test_catalog_match_takes_the_newest_of_a_family(self):
"""The bare family rungs must land on the current generation.
diff --git a/tests/agent/test_title_generator.py b/tests/agent/test_title_generator.py
index a95a56a5b18..1cdf0950bf7 100644
--- a/tests/agent/test_title_generator.py
+++ b/tests/agent/test_title_generator.py
@@ -278,6 +278,24 @@ class TestMaybeAutoTitle:
assert db.get_session_title("sess-1") is None
mock_auto.assert_not_called()
+ @pytest.mark.parametrize(
+ "opener",
+ [
+ "[CONTEXT COMPACTION — REFERENCE ONLY] Earlier turns were compacted",
+ "[CONTEXT SUMMARY]: the user was refactoring the auth module",
+ "[System note: the user switched models]",
+ "[Runtime note: resumed from checkpoint]",
+ ],
+ )
+ def test_skips_every_shape_of_machine_authored_opener(self, tmp_path, opener):
+ """A session named after our own scaffolding is named after us."""
+ db = SessionDB(tmp_path / "state.db")
+ db.create_session(session_id="sess-1", source="cli")
+ with patch("agent.title_generator.auto_title_session") as mock_auto:
+ maybe_auto_title(db, "sess-1", opener, [])
+ assert db.get_session_title("sess-1") is None
+ mock_auto.assert_not_called()
+
def test_titles_on_a_later_turn_when_the_opener_was_not_titleable(self, tmp_path):
"""A session whose opener couldn't be titled gets named by a later turn.