feat(ai): support custom reasoning fields (#38227)

This commit is contained in:
Aiden Cline 2026-07-21 23:42:59 -05:00 committed by GitHub
commit 23483ea013
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 306 additions and 67 deletions

View file

@ -16,6 +16,7 @@ import { it } from "./lib/effect"
interface ModelOptions {
readonly modelID?: string
readonly compatibility?: ModelV2.Compatibility
readonly settings?: ModelV2.Info["settings"]
readonly headers?: ModelV2.Info["headers"]
readonly body?: ModelV2.Info["body"]
@ -28,6 +29,7 @@ const model = (packageName: string | undefined, options: ModelOptions = {}) =>
modelID: ModelV2.ID.make(options.modelID ?? "api-test-model"),
providerID: ProviderV2.ID.make("test-provider"),
name: "Test model",
compatibility: options.compatibility,
package: packageName,
settings: options.settings ?? {},
headers: options.headers ?? { "x-test": "header" },
@ -101,6 +103,7 @@ describe("SessionRunnerModel", () => {
Effect.gen(function* () {
const resolved = yield* SessionRunnerModel.fromCatalogModel(
model(ProviderV2.aisdk("@ai-sdk/openai-compatible"), {
compatibility: { reasoningField: "vendor_reasoning" },
settings: {
apiKey: "settings-secret",
baseURL: "https://compatible.example/v1",
@ -121,6 +124,7 @@ describe("SessionRunnerModel", () => {
expect(headers.authorization).toBe("Bearer settings-secret")
expect(resolved.route.id).toBe("openai-compatible-chat")
expect(resolved.compatibility?.reasoningField).toBe("vendor_reasoning")
expect(resolved.route.endpoint.baseURL).toBe("https://compatible.example/v1")
expect(resolved.route.defaults.http?.body).toEqual({})
}),