Skip to content

Commit 76f57f9

Browse files
authored
fix(server): preserve explicit effort for unknown Claude models (pingdotgg#20849)
1 parent b656dd7 commit 76f57f9

4 files changed

Lines changed: 40 additions & 2 deletions

File tree

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,25 @@ describe("compileClaudeModelSelection", () => {
4949
).toMatchObject({ effort: "high", promptEffort: "ultrathink" });
5050
});
5151

52+
it("keeps explicit effort for models missing from the local catalog", () => {
53+
expect(
54+
compileClaudeModelSelection(
55+
selection("claude-pool-model-not-in-catalog", [{ id: "effort", value: "max" }]),
56+
).effort,
57+
).toBe("max");
58+
expect(
59+
compileClaudeModelSelection(selection("claude-pool-model-not-in-catalog", [])).effort,
60+
).toBeUndefined();
61+
});
62+
63+
it("omits unsupported effort for models missing from the local catalog", () => {
64+
expect(
65+
compileClaudeModelSelection(
66+
selection("claude-pool-model-not-in-catalog", [{ id: "effort", value: "brutal" }]),
67+
).effort,
68+
).toBeUndefined();
69+
});
70+
5271
it("compiles the thinking toggle for models that expose it", () => {
5372
expect(
5473
compileClaudeModelSelection(selection("claude-haiku-4-5", [{ id: "thinking", value: false }]))

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,16 @@ describe("Claude model catalog", () => {
192192
assert.isFalse(hasValidClaudeManifestAdapters(malformed));
193193
});
194194

195+
it("preserves only SDK effort levels for uncatalogued models", () => {
196+
const catalog = catalogFromManifest(manifest());
197+
for (const effort of ["low", "medium", "high", "xhigh", "max"]) {
198+
assert.strictEqual(resolveClaudeCatalogEffort(catalog, "custom", ` ${effort} `), effort);
199+
}
200+
for (const effort of [undefined, null, "", " ", "brutal", "extreme", "HIGH", "ultrathink"]) {
201+
assert.isUndefined(resolveClaudeCatalogEffort(catalog, "custom", effort));
202+
}
203+
});
204+
195205
it("appends custom models with their own descriptors and keeps bare slugs opaque", () => {
196206
const catalog = scopeClaudeModelCatalog(catalogFromManifest(manifest()), [
197207
"synthetic",
@@ -215,7 +225,9 @@ describe("Claude model catalog", () => {
215225
]);
216226

217227
assert.strictEqual(resolveClaudeModelSlug(catalog, "synthetic"), "synthetic");
218-
assert.strictEqual(resolveClaudeCatalogEffort(catalog, "synthetic", "extreme"), undefined);
228+
assert.isUndefined(resolveClaudeCatalogEffort(catalog, "synthetic", "extreme"));
229+
assert.strictEqual(resolveClaudeCatalogEffort(catalog, "synthetic", "max"), "max");
230+
assert.strictEqual(normalizeClaudeCatalogEffort(catalog, "max", "synthetic"), "max");
219231

220232
assert.strictEqual(
221233
resolveClaudeCatalogEffort(catalog, "claude-custom-tuned", "brutal"),

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,13 @@ export function resolveClaudeCatalogEffort(
209209
model: string | null | undefined,
210210
raw: string | null | undefined,
211211
): string | undefined {
212+
if (!resolveClaudeCatalogModel(catalog, model)) {
213+
const effort = raw?.trim();
214+
return effort && ["low", "medium", "high", "xhigh", "max"].includes(effort)
215+
? effort
216+
: undefined;
217+
}
218+
212219
const caps = getClaudeCatalogModelCapabilities(catalog, model);
213220
const descriptors = getProviderOptionDescriptors({
214221
caps,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ it.layer(layerClaudeTextGenerationTest)("ClaudeTextGeneration", (it) => {
237237
body: "",
238238
},
239239
}),
240-
argsMustContain: `--model ${SYNTHETIC_CLAUDE_COLLIDING_ALIAS} --settings`,
240+
argsMustContain: `--model ${SYNTHETIC_CLAUDE_COLLIDING_ALIAS} --effort max --settings`,
241241
claudeConfig: { customModels: [SYNTHETIC_CLAUDE_COLLIDING_ALIAS] },
242242
},
243243
(textGeneration) =>

0 commit comments

Comments
 (0)