From 2ed487583bfba66848efc59b51dc8d23e8d93d16 Mon Sep 17 00:00:00 2001 From: Diego Rodrigues de Sa e Souza Date: Sat, 8 Aug 2026 12:03:24 -0300 Subject: [PATCH] fix(model-discovery): ingest capabilities.effort_tiers for synced models (#9160) Refs: base-red #9737 --- changelog.d/fixes/9160-fix.plan.md | 1 + src/lib/providerModels/modelDiscovery.ts | 13 ++++++- tests/unit/triage-bugs-2026-08-02.test.ts | 45 +++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 changelog.d/fixes/9160-fix.plan.md diff --git a/changelog.d/fixes/9160-fix.plan.md b/changelog.d/fixes/9160-fix.plan.md new file mode 100644 index 0000000000..d6ad2b567c --- /dev/null +++ b/changelog.d/fixes/9160-fix.plan.md @@ -0,0 +1 @@ +- fix(model-discovery): ingest capabilities.effort_tiers for synced models (#9160) diff --git a/src/lib/providerModels/modelDiscovery.ts b/src/lib/providerModels/modelDiscovery.ts index 60c12c9bd4..b11cd66785 100644 --- a/src/lib/providerModels/modelDiscovery.ts +++ b/src/lib/providerModels/modelDiscovery.ts @@ -112,7 +112,8 @@ function parseEffortList(rawList: unknown): string[] | undefined { .map((entry) => { const entryParsed = effortEntrySchema.safeParse(entry); if (!entryParsed.success) return null; - const raw = typeof entryParsed.data === "string" ? entryParsed.data : entryParsed.data.effort; + const raw = + typeof entryParsed.data === "string" ? entryParsed.data : entryParsed.data.effort; return raw.length > 0 ? normalizeSupportedEffort(raw) : null; }) .filter((effort): effort is string => effort !== null) @@ -144,6 +145,16 @@ export function detectSupportedThinkingEfforts(record: JsonRecord): string[] | u } } + // #9160: fall back to `capabilities.effort_tiers` before the legacy fields. + // OmniRoute's own catalog surfaces effort tiers inside `capabilities.effort_tiers`, + // which the existing `parseEffortList` already handles (string arrays). + const capabilitiesRecord = asRecord(record.capabilities); + const capabilitiesParsed = effortListSchema.safeParse(capabilitiesRecord.effort_tiers); + if (capabilitiesParsed.success) { + const fromCapabilities = parseEffortList(capabilitiesRecord.effort_tiers); + if (fromCapabilities) return fromCapabilities; + } + // #8347: fall back to `supported_reasoning_levels`, then `thinking.levels` — in that // order, per the regression guard for #7694 (the flat field and `reasoning.supported_efforts` // both take precedence over these two and are handled above / by the caller). diff --git a/tests/unit/triage-bugs-2026-08-02.test.ts b/tests/unit/triage-bugs-2026-08-02.test.ts index 88a7cbb300..32b2879e78 100644 --- a/tests/unit/triage-bugs-2026-08-02.test.ts +++ b/tests/unit/triage-bugs-2026-08-02.test.ts @@ -42,6 +42,26 @@ test("non-GPT-5.6 models still get max downgraded to xhigh", () => { ) ); assert.equal(translated.reasoning_effort, "xhigh"); +<<<<<<< HEAD +}); + +// ───────────────────────────────────────────────────────────────────── +// PR #9142 — Anthropic top-level `system` prompts must trigger background detection +// ───────────────────────────────────────────────────────────────────── +const { getBackgroundTaskReason, setBackgroundDegradationConfig } = + await import("../../open-sse/services/backgroundTaskDetector.ts"); + +test("#9142 Anthropic top-level system prompts must trigger background detection", () => { + setBackgroundDegradationConfig({ enabled: true }); + assert.equal( + getBackgroundTaskReason({ + system: "Generate a title for this conversation", + messages: [{ role: "user", content: "hello" }], + }), + "system_prompt_pattern" + ); +}); +======= // #9140 — VS Code routes filter out built-in auto models const { isUsableChatModel } = await import( @@ -59,3 +79,28 @@ test("#9140 VS Code listing must accept built-in auto routing entries", () => { false, "operator-created combo should still be rejected" ); +>>>>>>> origin/release/v3.8.50 + + +}); + +// ── #9160 model discovery: capabilities.effort_tiers ──────────────────────── + +// #9160: model discovery must ingest capabilities.effort_tiers +test("#9160 model discovery must ingest capabilities.effort_tiers", () => { + assert.deepEqual( + detectSupportedThinkingEfforts({ + capabilities: { effort_tiers: ["low", "medium", "high", "xhigh"] }, + }), + ["low", "medium", "high", "xhigh"] + ); +}); + +test("#9160 capabilities.effort_tiers with duplicate and synonym", () => { + assert.deepEqual( + detectSupportedThinkingEfforts({ + capabilities: { effort_tiers: ["low", "low", "max"] }, + }), + ["low", "xhigh"] + ); +