fix(core): seed configured limits before model transforms (#55778)

Co-authored-by: Daniel Smolsky <dannysmo@gmail.com>
This commit is contained in:
Dante
2026-10-16 06:26:21 +08:00
committed by GitHub
Unverified
parent e89206d397
commit 7a4a03212e
2 changed files with 16 additions and 0 deletions
@@ -90,6 +90,14 @@ export const Plugin = define({
}
next.set(item, { providerID, models: definitions })
}
for (const [item, definition] of next) {
for (const [id, config] of Object.entries(item.models ?? {})) {
if (config.limit === undefined) continue
providers.models.update(definition.providerID, id, (model) => {
model.limit = { ...model.limit, ...config.limit }
})
}
}
sources.defaultModel = Config.latest(loaded.entries, "model")
sources.models = next
})
@@ -889,7 +889,15 @@ describe("ConfigProviderPlugin.Plugin", () => {
model.variants = [{ id: Model.VariantID.make("fast"), settings: { effort: "high" } }]
})
})
let transformed: Model.Info["limit"] | undefined
yield* models.transform((editor) => {
const model = editor.get(providerID, modelID)
if (!model) return
transformed = { ...model.limit }
model.limit = { context: 10, output: 1 }
})
yield* addPlugin(entries)
expect(transformed).toEqual({ context: 100, output: 75 })
const provider = required(yield* providers.get(providerID))
const model = required(yield* models.get(providerID, modelID))