Skip to content

Commit 32a123a

Browse files
committed
fix(core): expose model reasoning capability
Port of anomalyco#50283 to the V2 line (the original PR was closed by the V1→V2 dev promotion sweep, not by review). Fixes anomalyco#50257. The models.dev catalog's reasoning flag is still dropped on current dev, so the desktop model picker reports "No reasoning" for every model — 160 models / 0 with capabilities.reasoning on 2.0.20, still reproducible on 2.0.26. - schema: Model.Capabilities gains an optional reasoning field - core: models.dev materialization and mergeCapabilities thread it through, so provider config overlays no longer drop it - app: model mapper derived capabilities.reasoning from the catalog instead of hardcoding false - client: regenerated API types via bun run generate - tests: app mapper coverage + models.dev fixtures
1 parent 62ae125 commit 32a123a

7 files changed

Lines changed: 31 additions & 7 deletions

File tree

‎packages/app/src/runtime/server/global-sync/utils.test.ts‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe("normalizeProviderList", () => {
4848
modelID: "gpt-5",
4949
providerID: "openai",
5050
name: "GPT-5",
51-
capabilities: { tools: true, input: ["text", "image"], output: ["text"] },
51+
capabilities: { tools: true, reasoning: true, input: ["text", "image"], output: ["text"] },
5252
variants: [{ id: "high" }],
5353
time: { released: 1 },
5454
cost: [{ input: 1, output: 2, cache: { read: 0.1, write: 0.2 } }],
@@ -69,6 +69,19 @@ describe("normalizeProviderList", () => {
6969
enabled: true,
7070
limit: { context: 1, output: 1 },
7171
},
72+
{
73+
id: "gpt-classic",
74+
modelID: "gpt-classic",
75+
providerID: "openai",
76+
name: "GPT Classic",
77+
capabilities: { tools: true, input: ["text"], output: ["text"] },
78+
variants: [],
79+
time: { released: 0 },
80+
cost: [],
81+
status: "active",
82+
enabled: true,
83+
limit: { context: 1, output: 1 },
84+
},
7285
] as ModelListOutput["data"],
7386
)
7487

@@ -78,10 +91,12 @@ describe("normalizeProviderList", () => {
7891
expect(result.all.get("openai")?.models["gpt-5"]).toMatchObject({
7992
id: "gpt-5",
8093
providerID: "openai",
81-
capabilities: { toolcall: true, attachment: true },
94+
capabilities: { toolcall: true, attachment: true, reasoning: true },
8295
cost: { input: 1, output: 2 },
8396
variants: { high: {} },
8497
})
98+
// Models without a catalog reasoning flag map to false instead of being hardcoded
99+
expect(result.all.get("openai")?.models["gpt-classic"]?.capabilities.reasoning).toBe(false)
85100
})
86101
})
87102

‎packages/app/src/runtime/server/global-sync/utils.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export function normalizeProviderList(
7979
family: model.family,
8080
capabilities: {
8181
temperature: false,
82-
reasoning: false,
82+
reasoning: model.capabilities.reasoning ?? false,
8383
attachment: model.capabilities.input.some((item) => item !== "text"),
8484
toolcall: model.capabilities.tools,
8585
input: {

‎packages/client/src/promise/generated/types.ts‎

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/core/src/model.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ export type Capabilities = Model.Capabilities
3030

3131
/** Merges partial config capabilities onto a base model's capabilities, defaulting unset fields. */
3232
export const mergeCapabilities = (config: Partial<Capabilities>, base: Capabilities | undefined) => {
33-
const fallback = base ?? Capabilities.default()
33+
const fallback: Capabilities = base ?? Capabilities.default()
3434
return {
3535
tools: config.tools ?? fallback.tools,
36+
reasoning: config.reasoning ?? fallback.reasoning,
3637
input: [...(config.input ?? fallback.input)],
3738
output: [...(config.output ?? fallback.output)],
3839
temperature: config.temperature ?? base?.temperature,

‎packages/core/src/models-dev.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ function modelInfo(
441441
settings: Object.keys(settings).length === 0 ? undefined : settings,
442442
capabilities: {
443443
tools: model.capabilities.tools.supported,
444+
reasoning: model.capabilities.reasoning.supported,
444445
input: modalities(model.modalities.input),
445446
output: modalities(model.modalities.output),
446447
temperature: model.capabilities.temperature,

‎packages/core/test/models.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const fixtureSnapshot = [
9292
family: undefined,
9393
package: undefined,
9494
settings: { provider: "acme" },
95-
capabilities: { tools: true, input: ["text"], output: ["text"], temperature: true },
95+
capabilities: { tools: true, reasoning: false, input: ["text"], output: ["text"], temperature: true },
9696
variants: [],
9797
time: { released: Date.parse("2026-01-01") },
9898
cost: zeroCost,
@@ -143,7 +143,7 @@ const fixture2Snapshot = [
143143
family: undefined,
144144
package: undefined,
145145
settings: { provider: "beta" },
146-
capabilities: { tools: false, input: ["text"], output: ["text"], temperature: false },
146+
capabilities: { tools: false, reasoning: false, input: ["text"], output: ["text"], temperature: false },
147147
variants: [],
148148
time: { released: Date.parse("2026-02-01") },
149149
cost: zeroCost,

‎packages/schema/src/model.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export const Overlays = {
7777
export interface Capabilities extends Schema.Schema.Type<typeof Capabilities> {}
7878
export const Capabilities = Schema.Struct({
7979
tools: Schema.Boolean,
80+
reasoning: optional(Schema.Boolean),
8081
input: Schema.Array(Schema.String),
8182
output: Schema.Array(Schema.String),
8283
/** Whether the model accepts a sampling temperature. Unknown when unset. */

0 commit comments

Comments
 (0)