diff --git a/CHANGELOG.md b/CHANGELOG.md index 4da00877..c531fefd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +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 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 23943fb6..3123ac43 100644 --- a/src/server/__tests__/title-service.test.ts +++ b/src/server/__tests__/title-service.test.ts @@ -323,6 +323,35 @@ 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('language the user writes in') + expect(system).toContain('排查 CI 上的测试失败') + } 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 ed8a08f8..f71967fa 100644 --- a/src/server/services/titleService.ts +++ b/src/server/services/titleService.ts @@ -12,6 +12,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 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. Good examples: @@ -19,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"}