Skip to content

Commit 95503c1

Browse files
authored
fix(core): send reasoning.effort for GPT-5.6+ on Bedrock Converse (#48195)
1 parent ba14483 commit 95503c1

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

packages/core/src/aisdk-native.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ function mapBedrockRequest(input: MapInput): Pick<Mapping, "headers" | "body"> {
210210
const reasoning = isRecord(settings.reasoningConfig) ? settings.reasoningConfig : undefined
211211
const anthropic = input.modelID.includes("anthropic")
212212
const openai = input.modelID.includes("openai.")
213+
// Converse passes OpenAI fields through verbatim. gpt-oss (Harmony) takes the
214+
// flat chat-completions `reasoning_effort`; GPT-5.6+ reject it and take the
215+
// Responses-style `reasoning.effort` instead.
216+
const harmony = input.modelID.includes("openai.gpt-oss")
213217
const effort = typeof reasoning?.maxReasoningEffort === "string" ? reasoning.maxReasoningEffort : undefined
214218
const type = typeof reasoning?.type === "string" ? reasoning.type : undefined
215219
const budget = typeof reasoning?.budgetTokens === "number" ? reasoning.budgetTokens : undefined
@@ -236,7 +240,10 @@ function mapBedrockRequest(input: MapInput): Pick<Mapping, "headers" | "body"> {
236240
},
237241
}
238242
: {}),
239-
...(!anthropic && openai && effort !== undefined ? { reasoning_effort: effort } : {}),
243+
...(!anthropic && openai && harmony && effort !== undefined ? { reasoning_effort: effort } : {}),
244+
...(!anthropic && openai && !harmony && effort !== undefined
245+
? { reasoning: { ...(isRecord(additional.reasoning) ? additional.reasoning : {}), effort } }
246+
: {}),
240247
...(!anthropic && !openai && effort !== undefined
241248
? {
242249
reasoningConfig: {

packages/core/test/aisdk-native.test.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,28 @@ describe("AISDKNative", () => {
251251
},
252252
})
253253

254-
for (const modelID of ["openai.gpt-oss-120b-1:0", "global.openai.gpt-5.6-sol", "us.openai.gpt-5.6-sol"]) {
254+
// gpt-oss (Harmony) keeps the flat chat-completions field.
255+
expect(
256+
map("@ai-sdk/amazon-bedrock", { reasoningConfig: { maxReasoningEffort: "high" } }, "openai.gpt-oss-120b-1:0")
257+
?.body,
258+
).toEqual({ additionalModelRequestFields: { reasoning_effort: "high" } })
259+
260+
// GPT-5.6+ reject `reasoning_effort` and take the Responses-style nested field.
261+
for (const modelID of ["global.openai.gpt-5.6-sol", "us.openai.gpt-5.6-sol", "us.openai.gpt-6-astra"]) {
255262
expect(
256-
map("@ai-sdk/amazon-bedrock", { reasoningConfig: { maxReasoningEffort: "high" } }, modelID)?.body,
257-
).toEqual({ additionalModelRequestFields: { reasoning_effort: "high" } })
263+
map("@ai-sdk/amazon-bedrock", { reasoningConfig: { maxReasoningEffort: "none" } }, modelID)?.body,
264+
).toEqual({ additionalModelRequestFields: { reasoning: { effort: "none" } } })
258265
}
266+
expect(
267+
map(
268+
"@ai-sdk/amazon-bedrock",
269+
{
270+
reasoningConfig: { maxReasoningEffort: "high" },
271+
additionalModelRequestFields: { reasoning: { summary: "auto" } },
272+
},
273+
"us.openai.gpt-5.6-sol",
274+
)?.body,
275+
).toEqual({ additionalModelRequestFields: { reasoning: { summary: "auto", effort: "high" } } })
259276
})
260277

261278
test("maps Bedrock Mantle models to their supported native APIs", () => {

0 commit comments

Comments
 (0)