From 4a6d92ed77f2017db6e91c5825b3b54b4397c73e Mon Sep 17 00:00:00 2001 From: inverteum Date: Wed, 18 Nov 2026 14:43:33 +0000 Subject: [PATCH 1/2] fix(server): title prompt names the session and uses the user's language Tell the session-title model this is naming, not conversation: never answer or fulfill the message, and write the title in the user's primary language. Closes #277 --- CHANGELOG.md | 1 + src/server/__tests__/title-service.test.ts | 28 ++++++++++++++++++++++ src/server/services/titleService.ts | 2 ++ 3 files changed, 31 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d527c1e..3a25396b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ All notable changes to DreamCoder will be documented in this file. ### Fixed +- Session title generation tells the model to name the conversation instead of answering it, and to write the title in the user's language (#277). - A provider in OpenAI format whose base URL already ends in a version, such as `https://open.bigmodel.cn/api/paas/v4` or Gemini's `.../v1beta/openai`, works: requests, model lists and the connection test no longer add another `/v1`. Base URLs without a version still get `/v1` (#262). - A streamed reply through the local proxy is no longer cut off when the provider pauses for more than 60 seconds, and stopping a reply or deleting a session now also stops the request to the provider before it starts answering (#262). - With a manual HTTP proxy set in the network settings, the agent reaches the app's local proxy directly instead of sending those requests to the HTTP proxy (#262). diff --git a/src/server/__tests__/title-service.test.ts b/src/server/__tests__/title-service.test.ts index 30e1bb77..374b0eca 100644 --- a/src/server/__tests__/title-service.test.ts +++ b/src/server/__tests__/title-service.test.ts @@ -323,6 +323,34 @@ describe('titleService', () => { } }) + test('title prompt names the session instead of answering and uses the user language', async () => { + let requestBody: Record | null = null + const server = Bun.serve({ + hostname: '127.0.0.1', + port: 0, + async fetch(req) { + requestBody = await req.json() as Record + return Response.json({ + type: 'message', + content: [{ type: 'text', text: '{"title":"Trace ok"}' }], + }) + }, + }) + + try { + await writeLoggedProvider(server.port) + + await expect(generateTitle('帮我看看为什么 bun test 在 CI 上失败?')).resolves.toBe('Trace ok') + const system = requestBody?.system + expect(typeof system).toBe('string') + expect(system).toContain('title-generation task, not a conversation') + expect(system).toContain('Never answer the user\'s question') + expect(system).toContain('user\'s primary language') + } finally { + server.stop(true) + } + }) + test('logs why the title request failed upstream', async () => { const server = Bun.serve({ hostname: '127.0.0.1', diff --git a/src/server/services/titleService.ts b/src/server/services/titleService.ts index d3596e63..05540544 100644 --- a/src/server/services/titleService.ts +++ b/src/server/services/titleService.ts @@ -11,6 +11,8 @@ const TITLE_LOG_EXCERPT_LEN = 200 const TITLE_SYSTEM_PROMPT = `Generate a concise, sentence-case title (3-7 words) that captures the main topic or goal of this coding session. The title should be clear enough that the user recognizes the session in a list. Use sentence case: capitalize only the first word and proper nouns. +This is a title-generation task, not a conversation. Never answer the user's question or fulfill their request. Write the title in the user's primary language. + Return JSON with a single "title" field. Good examples: From 045b1097119f3e295567b236a75274f61eb2050e Mon Sep 17 00:00:00 2001 From: inverteum Date: Sat, 21 Nov 2026 19:46:55 +0800 Subject: [PATCH 2/2] fix(server): title prompt uses the user's language and a Chinese example Reword the language sentence, keep the don't-answer line, add a Chinese good example, update the title-service regression phrases, rewrite the CHANGELOG Fixed entry for #285, and mark T-SYS-09 fixed. --- CHANGELOG.md | 2 +- docs/features/harness/prompt/system.md | 1 + src/server/__tests__/title-service.test.ts | 3 ++- src/server/services/titleService.ts | 3 ++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2223bf41..c531fefd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,7 +35,7 @@ All notable changes to DreamCoder will be documented in this file. - **Stopping a reply keeps the session's context.** Stop ends the agent process only when the reply has not stopped a few seconds after you press Stop, and a restarted agent keeps uploaded images and files, instruction files from subfolders and files restored after compaction, without adding a "Continue from where you left off." message (#270). - The agent knows the available skills again after compaction, gets only newly added skills when the skill folders change, and does not get the whole list again after a restart (#270). - **`/goal` keeps working until the goal is met.** Before, the turn ended at the first check that found the goal unmet. Each automatic continuation now tells the agent the goal, what is still missing and how many continuations are left. The turn ends and the goal stays active when the agent needs something only you can provide, or after 10 continuations in a row without a message from you (#270). -- Session title generation tells the model to name the conversation instead of answering it, and to write the title in the user's language (#277). +- Session titles are written in the language of your message instead of English, and no longer answer the message (#285). Thanks @inverteum. - A provider in OpenAI format whose base URL already ends in a version, such as `https://open.bigmodel.cn/api/paas/v4` or Gemini's `.../v1beta/openai`, works: requests, model lists and the connection test no longer add another `/v1`. Base URLs without a version still get `/v1` (#262). - A streamed reply through the local proxy is no longer cut off when the provider pauses for more than 60 seconds, and stopping a reply or deleting a session now also stops the request to the provider before it starts answering (#262). - With a manual HTTP proxy set in the network settings, the agent reaches the app's local proxy directly instead of sending those requests to the HTTP proxy (#262). diff --git a/docs/features/harness/prompt/system.md b/docs/features/harness/prompt/system.md index a2d012f2..743ff5d5 100644 --- a/docs/features/harness/prompt/system.md +++ b/docs/features/harness/prompt/system.md @@ -208,6 +208,7 @@ ### T-SYS-09 服务端标题提示词没有「不要回答」和「用用户的语言」 +- 状态:已修复(#285):标题提示词要求用用户写的语言写标题、不要回答用户消息,并增加中文示例。 - 类型:问题 - 严重程度:低 - 体量:700 字符,每个会话 2 次(第 1、3 条用户消息后)。 diff --git a/src/server/__tests__/title-service.test.ts b/src/server/__tests__/title-service.test.ts index 646aff9f..3123ac43 100644 --- a/src/server/__tests__/title-service.test.ts +++ b/src/server/__tests__/title-service.test.ts @@ -345,7 +345,8 @@ describe('titleService', () => { expect(typeof system).toBe('string') expect(system).toContain('title-generation task, not a conversation') expect(system).toContain('Never answer the user\'s question') - expect(system).toContain('user\'s primary language') + expect(system).toContain('language the user writes in') + expect(system).toContain('排查 CI 上的测试失败') } finally { server.stop(true) } diff --git a/src/server/services/titleService.ts b/src/server/services/titleService.ts index 42e19be7..f71967fa 100644 --- a/src/server/services/titleService.ts +++ b/src/server/services/titleService.ts @@ -12,7 +12,7 @@ const TITLE_LOG_EXCERPT_LEN = 200 const TITLE_SYSTEM_PROMPT = `Generate a concise, sentence-case title (3-7 words) that captures the main topic or goal of this coding session. The title should be clear enough that the user recognizes the session in a list. Use sentence case: capitalize only the first word and proper nouns. -This is a title-generation task, not a conversation. Never answer the user's question or fulfill their request. Write the title in the user's primary language. +This is a title-generation task, not a conversation. Never answer the user's question or fulfill their request. Write the title in the language the user writes in, even when the message contains English code, commands or product names: a Chinese message gets a Chinese title. Return JSON with a single "title" field. @@ -21,6 +21,7 @@ Good examples: {"title": "Add OAuth authentication"} {"title": "Debug failing CI tests"} {"title": "Refactor API client error handling"} +{"title": "排查 CI 上的测试失败"} Bad (too vague): {"title": "Code changes"} Bad (too long): {"title": "Investigate and fix the issue where the login button does not respond on mobile devices"}