feat(core): widen interleaved reasoning fields

This commit is contained in:
Aiden Cline 2026-07-18 11:11:45 -05:00
commit f28cc51f12
13 changed files with 140 additions and 37 deletions

View file

@ -69,6 +69,9 @@ export const Plugin = define({
tools: config.capabilities.tools,
input: [...config.capabilities.input],
output: [...config.capabilities.output],
...(config.capabilities.interleaved !== undefined
? { interleaved: config.capabilities.interleaved }
: {}),
}
}
if (config.variants !== undefined) {

View file

@ -12,6 +12,12 @@ export type VariantID = typeof VariantID.Type
export const Family = Model.Family
export type Family = Model.Family
export const InterleavedField = Model.InterleavedField
export type InterleavedField = Model.InterleavedField
export const Interleaved = Model.Interleaved
export type Interleaved = Model.Interleaved
export const Capabilities = Model.Capabilities
export type Capabilities = Model.Capabilities

View file

@ -46,7 +46,7 @@ type SourceModel = {
readonly reasoning_options?: readonly ReasoningOption[]
readonly temperature?: boolean
readonly tool_call: boolean
readonly interleaved?: true | { readonly field: "reasoning" | "reasoning_content" | "reasoning_details" }
readonly interleaved?: ModelV2.Interleaved
readonly cost?: Cost
readonly limit: { readonly context: number; readonly input?: number; readonly output: number }
readonly modalities?: { readonly input: readonly Modality[]; readonly output: readonly Modality[] }
@ -505,6 +505,7 @@ function modelInfo(
tools: model.tool_call,
input: [...(model.modalities?.input ?? [])],
output: [...(model.modalities?.output ?? [])],
...(model.interleaved !== undefined ? { interleaved: model.interleaved } : {}),
},
variants: [...(input.variants ?? [])],
time: { released: released(model.release_date) },

View file

@ -271,8 +271,16 @@ function migrateModel(info: typeof ConfigProviderV1.Model.Type) {
: []),
]
const capabilities =
info.tool_call !== undefined || info.modalities?.input !== undefined || info.modalities?.output !== undefined
? { tools: info.tool_call ?? false, input: info.modalities?.input ?? [], output: info.modalities?.output ?? [] }
info.tool_call !== undefined ||
info.modalities?.input !== undefined ||
info.modalities?.output !== undefined ||
info.interleaved !== undefined
? {
tools: info.tool_call ?? false,
input: info.modalities?.input ?? [],
output: info.modalities?.output ?? [],
...(info.interleaved !== undefined ? { interleaved: info.interleaved } : {}),
}
: undefined
return {
modelID: info.id,

View file

@ -1,6 +1,7 @@
export * as ConfigProviderV1 from "./provider"
import { Schema } from "effect"
import { Interleaved } from "@opencode-ai/schema/model"
import { PositiveInt } from "../../schema"
export const ModelStatus = Schema.Literals(["alpha", "beta", "deprecated", "active"])
@ -14,14 +15,7 @@ export const Model = Schema.Struct({
reasoning: Schema.optional(Schema.Boolean),
temperature: Schema.optional(Schema.Boolean),
tool_call: Schema.optional(Schema.Boolean),
interleaved: Schema.optional(
Schema.Union([
Schema.Literal(true),
Schema.Struct({
field: Schema.Literals(["reasoning", "reasoning_content", "reasoning_details"]),
}),
]),
),
interleaved: Schema.optional(Interleaved),
cost: Schema.optional(
Schema.Struct({
input: Schema.Finite,

View file

@ -289,6 +289,24 @@ describe("Config", () => {
}),
)
it.effect("migrates provider-specific interleaved reasoning fields", () =>
Effect.sync(() => {
const migrated = ConfigMigrateV1.migrate({
provider: {
custom: {
models: {
chat: { interleaved: { field: "vendor_reasoning" } },
},
},
},
})
expect(migrated.providers?.custom?.models?.chat?.capabilities?.interleaved).toEqual({
field: "vendor_reasoning",
})
}),
)
it.effect("migrates v1 provider lists to policies", () =>
Effect.sync(() => {
expect(

View file

@ -170,7 +170,12 @@ describe("ConfigProviderPlugin.Plugin", () => {
models: {
chat: {
name: "First",
capabilities: { tools: true, input: ["text"], output: ["text"] },
capabilities: {
tools: true,
input: ["text"],
output: ["text"],
interleaved: { field: "vendor_reasoning" },
},
disabled: true,
limit: { context: 100, output: 50 },
cost: { input: 1, output: 2 },
@ -251,7 +256,12 @@ describe("ConfigProviderPlugin.Plugin", () => {
expect(model.id).toBe(modelID)
expect(model.modelID).toBe(ModelV2.ID.make("api-chat"))
expect(model.name).toBe("Last")
expect(model.capabilities).toEqual({ tools: true, input: ["text"], output: ["text"] })
expect(model.capabilities).toEqual({
tools: true,
input: ["text"],
output: ["text"],
interleaved: { field: "vendor_reasoning" },
})
expect(model.enabled).toBe(false)
expect(model.limit).toEqual({ context: 100, output: 75 })
expect(model.cost).toEqual([

View file

@ -47,6 +47,7 @@ const fixture = {
reasoning: false,
temperature: true,
tool_call: true,
interleaved: { field: "vendor_reasoning" },
limit: { context: 128000, output: 8192 },
},
},
@ -69,7 +70,7 @@ const fixtureSnapshot = [
family: undefined,
package: undefined,
settings: undefined,
capabilities: { tools: true, input: [], output: [] },
capabilities: { tools: true, input: [], output: [], interleaved: { field: "vendor_reasoning" } },
variants: [],
time: { released: Date.parse("2026-01-01") },
cost: [