fix(provider): only set thinkingConfig for models with reasoning capability (#18283)
This commit is contained in:
@@ -755,11 +755,13 @@ export namespace ProviderTransform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (input.model.api.npm === "@ai-sdk/google" || input.model.api.npm === "@ai-sdk/google-vertex") {
|
if (input.model.api.npm === "@ai-sdk/google" || input.model.api.npm === "@ai-sdk/google-vertex") {
|
||||||
result["thinkingConfig"] = {
|
if (input.model.capabilities.reasoning) {
|
||||||
includeThoughts: true,
|
result["thinkingConfig"] = {
|
||||||
}
|
includeThoughts: true,
|
||||||
if (input.model.api.id.includes("gemini-3")) {
|
}
|
||||||
result["thinkingConfig"]["thinkingLevel"] = "high"
|
if (input.model.api.id.includes("gemini-3")) {
|
||||||
|
result["thinkingConfig"]["thinkingLevel"] = "high"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,72 @@ describe("ProviderTransform.options - setCacheKey", () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("ProviderTransform.options - google thinkingConfig gating", () => {
|
||||||
|
const sessionID = "test-session-123"
|
||||||
|
|
||||||
|
const createGoogleModel = (reasoning: boolean, npm: "@ai-sdk/google" | "@ai-sdk/google-vertex") =>
|
||||||
|
({
|
||||||
|
id: `${npm === "@ai-sdk/google" ? "google" : "google-vertex"}/gemini-2.0-flash`,
|
||||||
|
providerID: npm === "@ai-sdk/google" ? "google" : "google-vertex",
|
||||||
|
api: {
|
||||||
|
id: "gemini-2.0-flash",
|
||||||
|
url: npm === "@ai-sdk/google" ? "https://generativelanguage.googleapis.com" : "https://vertexai.googleapis.com",
|
||||||
|
npm,
|
||||||
|
},
|
||||||
|
name: "Gemini 2.0 Flash",
|
||||||
|
capabilities: {
|
||||||
|
temperature: true,
|
||||||
|
reasoning,
|
||||||
|
attachment: true,
|
||||||
|
toolcall: true,
|
||||||
|
input: { text: true, audio: false, image: true, video: false, pdf: true },
|
||||||
|
output: { text: true, audio: false, image: false, video: false, pdf: false },
|
||||||
|
interleaved: false,
|
||||||
|
},
|
||||||
|
cost: {
|
||||||
|
input: 0.001,
|
||||||
|
output: 0.002,
|
||||||
|
cache: { read: 0.0001, write: 0.0002 },
|
||||||
|
},
|
||||||
|
limit: {
|
||||||
|
context: 1_000_000,
|
||||||
|
output: 8192,
|
||||||
|
},
|
||||||
|
status: "active",
|
||||||
|
options: {},
|
||||||
|
headers: {},
|
||||||
|
}) as any
|
||||||
|
|
||||||
|
test("does not set thinkingConfig for google models without reasoning capability", () => {
|
||||||
|
const result = ProviderTransform.options({
|
||||||
|
model: createGoogleModel(false, "@ai-sdk/google"),
|
||||||
|
sessionID,
|
||||||
|
providerOptions: {},
|
||||||
|
})
|
||||||
|
expect(result.thinkingConfig).toBeUndefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
test("sets thinkingConfig for google models with reasoning capability", () => {
|
||||||
|
const result = ProviderTransform.options({
|
||||||
|
model: createGoogleModel(true, "@ai-sdk/google"),
|
||||||
|
sessionID,
|
||||||
|
providerOptions: {},
|
||||||
|
})
|
||||||
|
expect(result.thinkingConfig).toEqual({
|
||||||
|
includeThoughts: true,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test("does not set thinkingConfig for vertex models without reasoning capability", () => {
|
||||||
|
const result = ProviderTransform.options({
|
||||||
|
model: createGoogleModel(false, "@ai-sdk/google-vertex"),
|
||||||
|
sessionID,
|
||||||
|
providerOptions: {},
|
||||||
|
})
|
||||||
|
expect(result.thinkingConfig).toBeUndefined()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("ProviderTransform.options - gpt-5 textVerbosity", () => {
|
describe("ProviderTransform.options - gpt-5 textVerbosity", () => {
|
||||||
const sessionID = "test-session-123"
|
const sessionID = "test-session-123"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user