Skip to content

The agent that grows with you

fix(title): strip a quoted path's line-range suffix in the attachment-only guard

Hermes Agentce750ff15183
diff --git a/agent/title_generator.py b/agent/title_generator.py
index dce21a619e8..c8f771f9ac9 100644
--- a/agent/title_generator.py
+++ b/agent/title_generator.py
@@ -274,8 +274,12 @@ def _strip_one_wrapper(text: str) -> str:
# written backtick-quoted). Kept local so the titler doesn't import the
# context-reference machinery (circularity / startup cost) just to detect the
# attachment-only shape (#92068).
+_QUOTED = r"(?:`[^`\n]+`|\"[^\"\n]+\"|'[^'\n]+')"
+# Mirrors the canonical agent.context_references value shape: a quoted
+# (space-bearing) path may carry a ``:start[-end]`` line-range suffix, and a
+# bare path swallows its own range via ``\S+``.
_CONTEXT_REFERENCE_TOKEN_RE = re.compile(
- r"(?<![\w/])@(?:file|folder):(?:(?:`[^`\n]+`|\"[^\"\n]+\"|'[^'\n]+')|\S+)"
+ rf"(?<![\w/])@(?:file|folder):(?:{_QUOTED}(?::\d+(?:-\d+)?)?|\S+)"
)
diff --git a/tests/agent/test_title_generator.py b/tests/agent/test_title_generator.py
index 0eb300fa7a3..abe71edeff7 100644
--- a/tests/agent/test_title_generator.py
+++ b/tests/agent/test_title_generator.py
@@ -69,6 +69,12 @@ class TestGenerateTitle:
# Backtick-quoted (space-bearing) paths and @folder: refs too.
assert is_titleable_user_message("@file:`my file.txt`") is False
assert is_titleable_user_message("@folder:/some/dir") is False
+ # A quoted path with a line range is one reference token for the
+ # canonical parser (context_references.REFERENCE_PATTERN), so the
+ # guard must strip the range too, not leave ":3" behind as "prose".
+ assert is_titleable_user_message("@file:`my file.txt`:3") is False
+ assert is_titleable_user_message('@file:"spaced name.md":12-14') is False
+ assert is_titleable_user_message("@file:'single quoted.md':1") is False
# The background model-title path refuses the same opener.
assert generate_title(msg) is None