Skip to content

Commit 5188392

Browse files
committed
fix(server): Claude text generation only sends a chosen thinking setting
Text generation sent the thinking toggle's displayed value, so the manifest's On default became an explicit alwaysThinkingEnabled: true that overrode a user's own Claude Code setting. Send it only when the user chose it, as chat turns do.
1 parent bd87769 commit 5188392

3 files changed

Lines changed: 68 additions & 2 deletions

File tree

‎apps/server/src/provider/ClaudeModelCatalog.testFixtures.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ export const SYNTHETIC_CLAUDE_MODEL_CATALOG: ClaudeModelCatalog = {
7373
name: "Claude Synthetic Thinking",
7474
isCustom: false,
7575
capabilities: {
76-
optionDescriptors: [{ id: "thinking", label: "Thinking", type: "boolean" }],
76+
optionDescriptors: [
77+
{ id: "thinking", label: "Thinking", type: "boolean", currentValue: true },
78+
],
7779
},
7880
},
7981
runtime: {},

‎apps/server/src/textGeneration/ClaudeTextGeneration.test.ts‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,66 @@ it.layer(ClaudeTextGenerationTestLayer)("ClaudeTextGeneration", (it) => {
296296
),
297297
);
298298

299+
it.effect("sends thinking on when it is chosen for text generation", () =>
300+
withFakeClaudeEnv(
301+
{
302+
output: JSON.stringify({
303+
structured_output: {
304+
subject: "Add important change",
305+
body: "",
306+
},
307+
}),
308+
argsMustContain: '--settings {"disableAllHooks":true,"alwaysThinkingEnabled":true}',
309+
},
310+
(textGeneration) =>
311+
Effect.gen(function* () {
312+
const generated = yield* textGeneration.generateCommitMessage({
313+
cwd: process.cwd(),
314+
branch: "feature/claude-effect",
315+
stagedSummary: "M README.md",
316+
stagedPatch: "diff --git a/README.md b/README.md",
317+
modelSelection: createModelSelection(
318+
ProviderInstanceId.make("claudeAgent"),
319+
SYNTHETIC_CLAUDE_THINKING_MODEL,
320+
[{ id: "thinking", value: true }],
321+
),
322+
});
323+
324+
expect(generated.subject).toBe("Add important change");
325+
}),
326+
),
327+
);
328+
329+
it.effect("leaves thinking to Claude Code when none is chosen for text generation", () =>
330+
withFakeClaudeEnv(
331+
{
332+
output: JSON.stringify({
333+
structured_output: {
334+
subject: "Add important change",
335+
body: "",
336+
},
337+
}),
338+
argsMustContain: '--settings {"disableAllHooks":true} --tools',
339+
},
340+
(textGeneration) =>
341+
Effect.gen(function* () {
342+
const generated = yield* textGeneration.generateCommitMessage({
343+
cwd: process.cwd(),
344+
branch: "feature/claude-effect",
345+
stagedSummary: "M README.md",
346+
stagedPatch: "diff --git a/README.md b/README.md",
347+
modelSelection: createModelSelection(
348+
ProviderInstanceId.make("claudeAgent"),
349+
SYNTHETIC_CLAUDE_THINKING_MODEL,
350+
[],
351+
),
352+
});
353+
354+
expect(generated.subject).toBe("Add important change");
355+
}),
356+
),
357+
);
358+
299359
it.effect("keeps a configured custom alias opaque to the Claude CLI", () =>
300360
withFakeClaudeEnv(
301361
{

‎apps/server/src/textGeneration/ClaudeTextGeneration.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
toJsonSchemaObject,
3535
} from "./TextGenerationUtils.ts";
3636
import {
37+
getModelSelectionBooleanOptionValue,
3738
getModelSelectionStringOptionValue,
3839
getProviderOptionDescriptors,
3940
} from "@t3tools/shared/model";
@@ -168,8 +169,11 @@ export const makeClaudeTextGeneration = Effect.fn("makeClaudeTextGeneration")(fu
168169
const ultracode = isClaudeCatalogUltracodeEffort(resolvedEffort);
169170
const thinkingDescriptor = findDescriptor("thinking");
170171
const fastModeDescriptor = findDescriptor("fastMode");
172+
// Only a chosen value; otherwise Claude Code's own default applies, as in chat turns.
171173
const thinking =
172-
thinkingDescriptor?.type === "boolean" ? thinkingDescriptor.currentValue : undefined;
174+
thinkingDescriptor?.type === "boolean"
175+
? getModelSelectionBooleanOptionValue(resolvedModelSelection, "thinking")
176+
: undefined;
173177
const fastMode =
174178
fastModeDescriptor?.type === "boolean" ? fastModeDescriptor.currentValue : undefined;
175179
const settings = {

0 commit comments

Comments
 (0)