Skip to content

Commit 5c59ada

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 512165c commit 5c59ada

7 files changed

Lines changed: 25 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+
// 目录未标注 reasoning 的模型映射为 false,而不是被硬编码覆盖
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
@@ -81,7 +81,7 @@ export function normalizeProviderList(
8181
family: model.family,
8282
capabilities: {
8383
temperature: false,
84-
reasoning: false,
84+
reasoning: model.capabilities.reasoning ?? false,
8585
attachment: model.capabilities.input.some((item) => item !== "text"),
8686
toolcall: model.capabilities.tools,
8787
input: {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export type ModelMaxTokensField = "max_completion_tokens" | "max_tokens"
168168

169169
export type ModelCacheFormat = "anthropic" | "alibaba"
170170

171-
export type ModelCapabilities = { tools: boolean; input: Array<string>; output: Array<string>; temperature?: boolean }
171+
export type ModelCapabilities = { tools: boolean; reasoning?: boolean; input: Array<string>; output: Array<string>; temperature?: boolean }
172172

173173
export type MoneyUSDPerMillionTokens = number
174174

‎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
@@ -231,6 +231,7 @@ function modelInfo(
231231
settings: Object.keys(settings).length === 0 ? undefined : settings,
232232
capabilities: {
233233
tools: model.tool_call,
234+
reasoning: model.reasoning,
234235
input: [...(model.modalities?.input ?? [])],
235236
output: [...(model.modalities?.output ?? [])],
236237
temperature: model.temperature,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const fixtureSnapshot = [
6161
family: undefined,
6262
package: undefined,
6363
settings: { provider: "acme" },
64-
capabilities: { tools: true, input: [], output: [], temperature: true },
64+
capabilities: { tools: true, reasoning: false, input: [], output: [], temperature: true },
6565
variants: [],
6666
time: { released: Date.parse("2026-01-01") },
6767
cost: [
@@ -123,7 +123,7 @@ const fixture2Snapshot = [
123123
family: undefined,
124124
package: undefined,
125125
settings: { provider: "beta" },
126-
capabilities: { tools: false, input: [], output: [], temperature: false },
126+
capabilities: { tools: false, reasoning: true, input: [], output: [], temperature: false },
127127
variants: [],
128128
time: { released: Date.parse("2026-02-01") },
129129
cost: [

‎packages/schema/src/model.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export const Overlays = {
6767
export interface Capabilities extends Schema.Schema.Type<typeof Capabilities> {}
6868
export const Capabilities = Schema.Struct({
6969
tools: Schema.Boolean,
70+
reasoning: optional(Schema.Boolean),
7071
input: Schema.Array(Schema.String),
7172
output: Schema.Array(Schema.String),
7273
/** Whether the model accepts a sampling temperature. Unknown when unset. */

0 commit comments

Comments
 (0)