Skip to content

Use Claude Code, Codex, VSCode, Pi, and OpenCode (and 6 other harnesses) for free (1.3B+ free tokens) from your terminal, app, IDE, or phone, and now from the browser with native browser sessions (multi-harness + multi-model) like OpenClaw (voice supported + ToS friendly)

Python

refactor: drop legacy title-generation detection copy

Alishahryar140951c145ad2
diff --git a/api/detection.py b/api/detection.py
index 18815295..a2991518 100644
--- a/api/detection.py
+++ b/api/detection.py
@@ -32,22 +32,18 @@ def is_title_generation_request(request_data: MessagesRequest) -> bool:
Title generation requests are detected by a system prompt containing
title extraction instructions, no tools, and a single user message.
- Matches both legacy phrasing and Claude Code 2.1+ session title prompts
- (JSON \"title\" field, sentence-case title instructions, etc.).
+ Matches Claude Code session title prompts (sentence-case title, JSON
+ \"title\" field, etc.).
"""
if not request_data.system or request_data.tools:
return False
system_text = extract_text_from_content(request_data.system).lower()
if "title" not in system_text:
return False
- return (
- "new conversation topic" in system_text
- or "sentence-case title" in system_text
- or (
- "return json" in system_text
- and "field" in system_text
- and ("coding session" in system_text or "this session" in system_text)
- )
+ return "sentence-case title" in system_text or (
+ "return json" in system_text
+ and "field" in system_text
+ and ("coding session" in system_text or "this session" in system_text)
)
diff --git a/smoke/prereq/test_api_prereq_live.py b/smoke/prereq/test_api_prereq_live.py
index 7f488fca..0ce41883 100644
--- a/smoke/prereq/test_api_prereq_live.py
+++ b/smoke/prereq/test_api_prereq_live.py
@@ -107,7 +107,10 @@ def test_optimization_fast_paths_do_not_need_provider(
"title",
{
"model": "claude-3-5-sonnet-20241022",
- "system": "Generate a title for the new conversation topic.",
+ "system": (
+ "Generate a concise, sentence-case title (3-7 words). "
+ 'Return JSON with a single "title" field.'
+ ),
"messages": [{"role": "user", "content": "hello"}],
},
"Conversation",
diff --git a/smoke/product/test_api_product_live.py b/smoke/product/test_api_product_live.py
index f525221b..0ae2d937 100644
--- a/smoke/product/test_api_product_live.py
+++ b/smoke/product/test_api_product_live.py
@@ -113,7 +113,10 @@ def test_api_request_optimizations_e2e(
"title",
{
"model": "claude-3-5-sonnet-20241022",
- "system": "Generate a title for the new conversation topic.",
+ "system": (
+ "Generate a concise, sentence-case title (3-7 words). "
+ 'Return JSON with a single "title" field.'
+ ),
"messages": [{"role": "user", "content": "hello"}],
},
"Conversation",
diff --git a/tests/api/test_request_utils.py b/tests/api/test_request_utils.py
index eb86dc75..6048c9d9 100644
--- a/tests/api/test_request_utils.py
+++ b/tests/api/test_request_utils.py
@@ -114,11 +114,15 @@ class TestTitleGenerationRequest:
def _title_gen_system(self) -> list[MagicMock]:
block = MagicMock()
- block.text = "Analyze if this message indicates a new conversation topic. If it does, extract a 2-3 word title."
+ block.text = (
+ "Generate a concise, sentence-case title (3-7 words) that captures the "
+ "main topic or goal of this coding session. Return JSON with a single "
+ '"title" field.'
+ )
return [block]
def test_title_generation_detected_via_system(self):
- """Title gen detected by system prompt containing topic/title keywords."""
+ """Title gen detected by session title system prompt (sentence-case / JSON)."""
req = MagicMock(spec=MessagesRequest)
req.system = self._title_gen_system()
req.tools = None
@@ -151,14 +155,10 @@ class TestTitleGenerationRequest:
assert is_title_generation_request(req) is False
- def test_title_generation_claude_code_session_title_prompt(self):
- """Claude Code 2.1+ session title JSON (sentence-case) is detected."""
+ def test_title_generation_return_json_coding_session_branch(self):
+ """JSON title field + session wording matches without sentence-case phrase."""
block = MagicMock()
- block.text = (
- "Generate a concise, sentence-case title (3-7 words) that captures the "
- "main topic or goal of this coding session. Return JSON with a single "
- '"title" field.'
- )
+ block.text = 'Return JSON with a single "title" field for this coding session.'
req = MagicMock(spec=MessagesRequest)
req.system = [block]
req.tools = None