fix(core): keep catalog capabilities when a v1 model override sets only some (#62573)

This commit is contained in:
Dan Smolsky
2026-11-09 23:46:18 -05:00
committed by GitHub
Unverified
parent 51ce52546c
commit 782650b036
2 changed files with 23 additions and 6 deletions
+1 -6
View File
@@ -230,14 +230,9 @@ function migrateModel(info: typeof ConfigProviderV1.Model.Type, npm: string | un
]
: []),
]
const defaults = Model.Capabilities.default()
const capabilities =
info.tool_call !== undefined || info.modalities?.input !== undefined || info.modalities?.output !== undefined
? {
tools: info.tool_call ?? defaults.tools,
input: info.modalities?.input ?? defaults.input,
output: info.modalities?.output ?? defaults.output,
}
? { tools: info.tool_call, input: info.modalities?.input, output: info.modalities?.output }
: undefined
return {
modelID: info.id,
@@ -765,6 +765,28 @@ describe("ConfigProviderPlugin.Plugin", () => {
}),
)
it.effect("keeps catalog capabilities that a migrated override omits", () =>
Effect.gen(function* () {
const providers = yield* Provider.Service
const models = yield* Model.Service
const providerID = Provider.ID.make("custom")
const modelID = Model.ID.make("chat")
yield* providers.transform((editor) => {
editor.models.update(providerID, modelID, (model) => {
model.capabilities = { tools: false, input: ["audio"], output: ["audio"] }
})
})
const result = ConfigNormalize.normalize({ provider: { custom: { models: { chat: { tool_call: true } } } } })
if (result.type !== "normalized") throw new Error("Expected normalized config")
yield* addPlugin([new Document({ type: "document", info: decode(result.encoded) })])
expect((yield* models.get(providerID, modelID))?.capabilities).toEqual({
tools: true,
input: ["audio"],
output: ["audio"],
})
}),
)
it.effect("lets a configured provider baseURL override catalog model baseURLs", () =>
Effect.gen(function* () {
const providers = yield* Provider.Service