Skip to content

Commit b4c5599

Browse files
Topficlaude
andcommitted
fix(server): generated thread titles leave out the project name
The title prompts ask the model to avoid project names already visible in the UI, but never say what the project is called, so titles often repeat it ("FireForge Source Mode vs Patches" under the FireForge project). Pass the project title into thread title generation and name it in the rule for initial and regenerated titles. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b8c2cfa commit b4c5599

8 files changed

Lines changed: 58 additions & 7 deletions

File tree

‎apps/server/src/orchestration-v2/ThreadTitleRegenerationService.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ const make = Effect.gen(function* () {
170170
const result = yield* textGeneration.generateThreadTitle({
171171
cwd: worktreeExists ? worktreePath : project.value.workspaceRoot,
172172
message: context.message,
173+
projectTitle: project.value.title,
173174
attachments: context.attachments,
174175
...(input.kind.type === "regenerate" ? { previousTitle: projection.thread.title } : {}),
175176
...(inherited === undefined ? {} : { forkSource: inherited }),

‎evals/thread-titles/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ pnpm thread-titles --model <codex model> --out runs/titles-new --baseline runs/t
1616

1717
## Add a case
1818

19-
Add an entry to `cases.ts` with an `id`, a `source`, the thread `messages`, the `previousTitle`, and a `rubric` that says what a good title names.
19+
Add an entry to `cases.ts` with an `id`, a `source`, the thread `messages`, the `previousTitle`, an optional `projectTitle`, and a `rubric` that says what a good title names.

‎evals/thread-titles/cases.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,29 @@ export const threadTitleEvaluationCases = [
106106
],
107107
rubric: "Keep title generation as the subject. Do not focus on filing the PR.",
108108
},
109+
{
110+
id: "project-name",
111+
source: "Titles repeating the project name shown beside them in the sidebar",
112+
request: "Make hyperdrive init create a default config instead of crashing.",
113+
projectTitle: "Hyperdrive",
114+
previousTitle: "Hyperdrive Init Missing Config Crash",
115+
messages: [
116+
{
117+
role: "user",
118+
text: "hyperdrive init crashes when ~/.hyperdrive/config.toml is missing. Make hyperdrive create a default config instead of throwing.",
119+
},
120+
{
121+
role: "assistant",
122+
text: "Hyperdrive's loadConfig now writes a default config.toml when the file is absent.",
123+
},
124+
],
125+
rubric: "Name the default config on init. Leave out Hyperdrive, the project name.",
126+
},
109127
] satisfies ReadonlyArray<{
110128
id: string;
111129
source: string;
112130
request: string;
131+
projectTitle?: string;
113132
previousTitle: string;
114133
messages: ReadonlyArray<ThreadTitleMessage>;
115134
rubric: string;

‎evals/thread-titles/run.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ await Effect.runPromise(
9595
const generated = yield* generation.generateThreadTitle({
9696
cwd,
9797
message,
98+
...("projectTitle" in fixture ? { projectTitle: fixture.projectTitle } : {}),
9899
previousTitle: values.initial ? undefined : fixture.previousTitle,
99100
attachments,
100101
linkedContext,

‎packages/provider-core/src/server/textGeneration.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export interface ThreadTitleGenerationInput {
6060
linkedContext?: string | undefined;
6161
cwd: string;
6262
message: string;
63+
projectTitle?: string | undefined;
6364
previousTitle?: string | undefined;
6465
forkSource?: ThreadTitleForkSource | undefined;
6566
attachments?: ReadonlyArray<ChatAttachment> | undefined;

‎packages/provider-core/src/server/textGenerationOperations.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ export function fromRunner(name: string, run: Runner): ProviderTextGeneration {
144144
attachments: input.attachments,
145145
...buildThreadTitlePrompt({
146146
message: input.message,
147+
projectTitle: input.projectTitle,
147148
previousTitle: input.previousTitle,
148149
forkSource: input.forkSource,
149150
linkedContext: input.linkedContext,

‎packages/provider-core/src/server/textGenerationPrompts.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, expect, it } from "vite-plus/test";
22

3+
import { buildThreadTitlePrompt } from "./textGenerationPrompts.ts";
34
import { normalizeCliError } from "./textGenerationUtils.ts";
45

56
describe("normalizeCliError", () => {
@@ -15,3 +16,16 @@ describe("normalizeCliError", () => {
1516
expect(result.message).not.toContain("secret-token");
1617
});
1718
});
19+
20+
describe("buildThreadTitlePrompt", () => {
21+
it("names the project to leave out of initial and regenerated titles", () => {
22+
for (const previousTitle of [undefined, "Hyperdrive Config Crash"]) {
23+
const { prompt } = buildThreadTitlePrompt({
24+
message: "hyperdrive init crashes without a config",
25+
previousTitle,
26+
projectTitle: "Hyperdrive",
27+
});
28+
expect(prompt).toContain('Never include the project name ("Hyperdrive")');
29+
}
30+
});
31+
});

‎packages/provider-core/src/server/textGenerationPrompts.ts‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ export function buildBranchNamePrompt(input: BranchNamePromptInput) {
353353
export interface ThreadTitlePromptInput {
354354
linkedContext?: string | undefined;
355355
message: string;
356+
projectTitle?: string | undefined;
356357
previousTitle?: string | undefined;
357358
forkSource?: ThreadTitleForkSource | undefined;
358359
attachments?: ReadonlyArray<ChatAttachment> | undefined;
@@ -365,8 +366,17 @@ export interface ThreadTitleForkSource {
365366
history: string;
366367
}
367368

369+
// The UI shows the project beside the title; naming it lets small models actually omit it.
370+
function avoidRule(projectTitle: string | undefined, others: string): string {
371+
const name = projectTitle?.trim();
372+
return name
373+
? `- Never include the project name (${JSON.stringify(name)}); the UI already shows it next to the title. Avoid ${others}.`
374+
: `- Avoid project names already visible in the UI, ${others}.`;
375+
}
376+
368377
// Keep shared editorial rules in these two prompts in sync.
369-
const INITIAL_THREAD_TITLE_PROMPT = `Generate a title that will help the user recognize this T3 Code thread weeks later.
378+
function initialThreadTitlePrompt(projectTitle: string | undefined): string {
379+
return `Generate a title that will help the user recognize this T3 Code thread weeks later.
370380
Return JSON with keys title and needsRefinement.
371381
Set needsRefinement to true only if the subject is still unknown, such as an unresolved link, "fix this", or an unexplained attachment. Otherwise set it to false.
372382
@@ -387,13 +397,17 @@ Editorial rules:
387397
- For research, name the question domain rather than the requested research process.
388398
- Do not claim the work is complete.
389399
- Do not copy and truncate the user's message.
390-
- Avoid project names already visible in the UI, quotes, labels, filler, and trailing punctuation.
400+
${avoidRule(projectTitle, "quotes, labels, filler, and trailing punctuation")}
391401
- Use attached images as primary context for UI issues.
392402
- When a URL or attachment is the only source of the subject, use available tools to inspect it directly.
393403
- Local git history is not evidence of what a linked PR or issue is about. Never title the thread after branch names, commit messages, or merged commits found in the checkout.
394404
- If a linked PR or issue cannot be read, fall back to the user's stated action plus its number, such as "Take Over PR 8588". This is the one case where a PR or issue number belongs in the title.`;
405+
}
395406

396-
function regenerateThreadTitlePrompt(previousTitle: string): string {
407+
function regenerateThreadTitlePrompt(
408+
previousTitle: string,
409+
projectTitle: string | undefined,
410+
): string {
397411
return `Regenerate the title for an existing T3 Code thread so the user can recognize it weeks later.
398412
The previous title was ${JSON.stringify(previousTitle)}.
399413
Return JSON with keys title and needsRefinement. Set needsRefinement to false.
@@ -416,7 +430,7 @@ Editorial rules:
416430
- For research, name the question domain rather than the research process.
417431
- Do not claim the work is complete.
418432
- Do not copy and truncate a thread message.
419-
- Avoid project names already visible in the UI, PR numbers, quotes, labels, filler, and trailing punctuation.
433+
${avoidRule(projectTitle, "PR numbers, quotes, labels, filler, and trailing punctuation")}
420434
- Use attached images as primary context for UI issues.
421435
- When a URL or attachment is the only source of the subject, use available tools to inspect it directly.
422436
- Local git history is not evidence of what a linked PR or issue is about. Never title the thread after branch names, commit messages, or merged commits found in the checkout.
@@ -472,12 +486,12 @@ export function buildThreadTitlePrompt(input: ThreadTitlePromptInput) {
472486
if (input.previousTitle === undefined) {
473487
const message = limitTitleMessage(input.message, 8_000);
474488
const label = input.forkSource === undefined ? "User message" : "User message after the fork";
475-
prompt = `${INITIAL_THREAD_TITLE_PROMPT}${forkSourceSection(input.forkSource)}\n\n${label}:\n${message}${threadTitlePromptSuffix(input)}`;
489+
prompt = `${initialThreadTitlePrompt(input.projectTitle)}${forkSourceSection(input.forkSource)}\n\n${label}:\n${message}${threadTitlePromptSuffix(input)}`;
476490
} else {
477491
const message = preserveMessageEnd(input.message);
478492
const label =
479493
input.forkSource === undefined ? "Thread contents" : "Thread contents after the fork";
480-
prompt = `${regenerateThreadTitlePrompt(input.previousTitle)}${forkSourceSection(input.forkSource)}\n\n${label}:\n${message}${threadTitlePromptSuffix(input)}`;
494+
prompt = `${regenerateThreadTitlePrompt(input.previousTitle, input.projectTitle)}${forkSourceSection(input.forkSource)}\n\n${label}:\n${message}${threadTitlePromptSuffix(input)}`;
481495
}
482496
const outputSchema = Schema.Struct({
483497
title: Schema.String,

0 commit comments

Comments
 (0)