fix(provider): normalize null reasoning efforts to none

The generated SDK flattens Schema.NullOr to plain strings, so the
runtime schema with (string | null)[] effort values no longer matched
the generated Provider type and typecheck failed on dev. models.dev
uses null to mean reasoning can be disabled; map it to "none" at
parse time and keep the public schema plain strings.
This commit is contained in:
Aiden Cline
2026-07-12 23:35:09 -05:00
parent cf7503687a
commit 8eef79784e
2 changed files with 8 additions and 4 deletions
+6 -2
View File
@@ -984,7 +984,7 @@ const ProviderInterleaved = Schema.Union([
const ProviderReasoningOption = Schema.Union([
Schema.Struct({
type: Schema.Literal("effort"),
values: Schema.Array(Schema.NullOr(Schema.String)),
values: Schema.Array(Schema.String),
}),
Schema.Struct({
type: Schema.Literal("toggle"),
@@ -1234,7 +1234,11 @@ function normalizeReasoningOption(option: unknown): ReasoningOption | undefined
if (!Array.isArray(option.values)) return
return {
type: "effort",
values: option.values.filter((value): value is string | null => value === null || typeof value === "string"),
// models.dev uses null to mean reasoning can be disabled; expose it as "none".
values: option.values.flatMap((value) => {
if (value === null) return ["none"]
return typeof value === "string" ? [value] : []
}),
}
}
if (option.type === "toggle") return { type: "toggle" }