Skip to content

Commit cbd3e14

Browse files
authored
perf(server): skip redundant claude session naming (#28910)
1 parent af00cf7 commit cbd3e14

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2601,6 +2601,7 @@ describe("ClaudeAdapterV2 MCP credential channel", () => {
26012601
...ClaudeAdapterV2.makeClaudeQueryOptions({
26022602
modelSelection: CLAUDE_TEST_MODEL_SELECTION,
26032603
nativeThreadId: "native-thread-claude-mcp-channel",
2604+
title: "Existing T3 title",
26042605
resume: false,
26052606
cwd: null,
26062607
environment: { PATH: "/usr/bin" },
@@ -2655,7 +2656,12 @@ describe("ClaudeAdapterV2 MCP credential channel", () => {
26552656
subtype: "mcp_set_servers",
26562657
servers: { "t3-code": t3McpServer },
26572658
});
2659+
assert.deepInclude(
2660+
cli.controlRequests.find((request) => Reflect.get(request, "subtype") === "initialize"),
2661+
{ title: "Existing T3 title" },
2662+
);
26582663
const spawned = JSON.stringify(cli.spawns);
2664+
assert.notInclude(spawned, "--title");
26592665
assert.notInclude(spawned, "--mcp-config");
26602666
assert.notInclude(spawned, "dummy-mcp-credential");
26612667
}),
@@ -2745,6 +2751,7 @@ describe("ClaudeAdapterV2 native session identity", () => {
27452751
assert.equal(openedQueries.length, 1);
27462752
assert.equal(openedQueries[0]?.options.resume, "native-session-identity");
27472753
assert.equal(openedQueries[0]?.options.sessionId, undefined);
2754+
assert.equal(openedQueries[0]?.options.title, "Claude attachment test");
27482755
}),
27492756
);
27502757

@@ -2753,6 +2760,7 @@ describe("ClaudeAdapterV2 native session identity", () => {
27532760
const openedQueries = yield* openTurnWithOrdinal(4, false);
27542761
assert.equal(openedQueries[0]?.options.sessionId, "native-session-identity");
27552762
assert.equal(openedQueries[0]?.options.resume, undefined);
2763+
assert.equal(openedQueries[0]?.options.title, "Claude attachment test");
27562764
}),
27572765
);
27582766
});

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,7 @@ const subagentDeviceInstructions: HookCallback = () =>
14681468
export function makeClaudeQueryOptions(input: {
14691469
readonly modelSelection: ModelSelection;
14701470
readonly nativeThreadId: string;
1471+
readonly title?: string;
14711472
readonly resume: boolean;
14721473
readonly resumeSessionAt?: string;
14731474
readonly cwd: string | null;
@@ -1548,6 +1549,8 @@ export function makeClaudeQueryOptions(input: {
15481549
const deviceInstructions = input.mcpServers !== undefined && input.deviceToolsAvailable === true;
15491550
const options: ClaudeAgentSdkQueryOptions = {
15501551
model: compiledSelection.apiModelId,
1552+
// T3 names threads; a supplied title skips Claude's redundant naming request.
1553+
...(input.title === undefined ? {} : { title: input.title }),
15511554
tools: claudeAgentSdkQueryToolsForSdk(selectedTools),
15521555
permissionMode:
15531556
(launchArgPermissionMode as PermissionMode | null | undefined) ??
@@ -10349,6 +10352,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
1034910352
const queryOptions = makeClaudeQueryOptions({
1035010353
modelSelection: turnInput.modelSelection,
1035110354
nativeThreadId,
10355+
title: turnInput.appThread.title,
1035210356
resume: shouldResume,
1035310357
...(resumeSessionAt === undefined ? {} : { resumeSessionAt }),
1035410358
cwd: turnInput.runtimePolicy.cwd,

0 commit comments

Comments
 (0)