Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
28 changes: 28 additions & 0 deletions src/server/__tests__/title-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,34 @@ describe('titleService', () => {
}
})

test('title prompt names the session instead of answering and uses the user language', async () => {
let requestBody: Record<string, unknown> | null = null
const server = Bun.serve({
hostname: '127.0.0.1',
port: 0,
async fetch(req) {
requestBody = await req.json() as Record<string, unknown>
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',
Expand Down
2 changes: 2 additions & 0 deletions src/server/services/titleService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading