Skip to content

Commit 28b264d

Browse files
committed
fix(claude): custom models keep Ultracode as a reasoning choice
Custom models keep their own capabilities, so they can still offer Ultracode as an effort choice with no toggle. Chat and text generation only read the toggle, so picking that effort dropped Ultracode. With no toggle they now turn it on from the effort, as before.
1 parent 79ca042 commit 28b264d

4 files changed

Lines changed: 82 additions & 2 deletions

File tree

‎apps/server/src/claudeModelOptions.test.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import { describe, expect, it } from "@effect/vitest";
33
import { ProviderInstanceId, type ModelSelection } from "@t3tools/contracts";
44

55
import { compileClaudeModelSelection } from "./claudeModelOptions.ts";
6+
import {
7+
BUNDLED_CLAUDE_MODEL_CATALOG,
8+
scopeClaudeModelCatalog,
9+
} from "./provider/ClaudeModelCatalog.ts";
610

711
const selection = (
812
model: string,
@@ -67,6 +71,33 @@ describe("compileClaudeModelSelection", () => {
6771
).settings,
6872
).not.toHaveProperty("ultracode");
6973
});
74+
it("keeps Ultracode on for custom models that offer it as an effort choice", () => {
75+
const catalog = scopeClaudeModelCatalog(BUNDLED_CLAUDE_MODEL_CATALOG, [
76+
{
77+
slug: "custom-ultracode",
78+
name: "Custom Ultracode",
79+
capabilities: {
80+
optionDescriptors: [
81+
{
82+
id: "effort",
83+
label: "Reasoning",
84+
type: "select",
85+
options: [
86+
{ id: "high", label: "High", isDefault: true },
87+
{ id: "ultracode", label: "Ultracode" },
88+
],
89+
},
90+
],
91+
},
92+
},
93+
]);
94+
expect(
95+
compileClaudeModelSelection(
96+
selection("custom-ultracode", [{ id: "effort", value: "ultracode" }]),
97+
catalog,
98+
).settings,
99+
).toEqual({ ultracode: true });
100+
});
70101
it("keeps a saved Ultracode effort at xhigh with Ultracode on", () => {
71102
expect(
72103
compileClaudeModelSelection(

‎apps/server/src/claudeModelOptions.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@ export function compileClaudeModelSelection(
4545
selections: selection.options,
4646
}).find((descriptor) => descriptor.id === "ultracode");
4747
// Explicit when supported, so an Off toggle overrides Ultracode set in the user's settings.json.
48+
// Custom models may still offer Ultracode as an effort choice.
4849
const ultracode =
4950
ultracodeDescriptor?.type === "boolean"
5051
? (ultracodeDescriptor.currentValue ?? false)
51-
: undefined;
52+
: resolvedEffort === "ultracode"
53+
? true
54+
: undefined;
5255
const settings = {
5356
...(typeof thinking === "boolean" ? { alwaysThinkingEnabled: thinking } : {}),
5457
...(typeof fastMode === "boolean" ? { fastMode } : {}),

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,50 @@ it.layer(layerClaudeTextGenerationTest)("ClaudeTextGeneration", (it) => {
236236
),
237237
);
238238

239+
it.effect("keeps Ultracode on for custom models that offer it as an effort choice", () =>
240+
withFakeClaudeEnv(
241+
{
242+
output: JSON.stringify({ structured_output: { title: "Title", body: "Body" } }),
243+
argsMustContain: `"ultracode":true}`,
244+
claudeConfig: {
245+
customModels: [
246+
{
247+
slug: "custom-ultracode",
248+
name: "Custom Ultracode",
249+
capabilities: {
250+
optionDescriptors: [
251+
{
252+
id: "effort",
253+
label: "Reasoning",
254+
type: "select",
255+
options: [
256+
{ id: "high", label: "High", isDefault: true },
257+
{ id: "ultracode", label: "Ultracode" },
258+
],
259+
},
260+
],
261+
},
262+
},
263+
],
264+
},
265+
},
266+
(textGeneration) =>
267+
textGeneration.generatePrContent({
268+
cwd: process.cwd(),
269+
baseBranch: "main",
270+
headBranch: "feature/ultracode",
271+
commitSummary: "Change",
272+
diffSummary: "1 file changed",
273+
diffPatch: "diff --git a/README.md b/README.md",
274+
modelSelection: createModelSelection(
275+
ProviderInstanceId.make("claudeAgent"),
276+
"custom-ultracode",
277+
[{ id: "effort", value: "ultracode" }],
278+
),
279+
}),
280+
),
281+
);
282+
239283
it.effect(
240284
"generates thread titles outside the project with tools, skills, and hooks disabled",
241285
() =>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ export const makeClaudeTextGeneration = Effect.fn("makeClaudeTextGeneration")(fu
169169
const fastMode =
170170
fastModeDescriptor?.type === "boolean" ? fastModeDescriptor.currentValue : undefined;
171171
const ultracode =
172-
ultracodeDescriptor?.type === "boolean" ? ultracodeDescriptor.currentValue : undefined;
172+
ultracodeDescriptor?.type === "boolean"
173+
? ultracodeDescriptor.currentValue
174+
: resolvedEffort === "ultracode";
173175
const settings = {
174176
disableAllHooks: true,
175177
...(typeof thinking === "boolean" ? { alwaysThinkingEnabled: thinking } : {}),

0 commit comments

Comments
 (0)