fix(kiro): map GPT-5.6 reasoning effort fields

Route GPT-5.6 reasoning effort through Kiro's native reasoning.effort field instead of the legacy Claude output_config.effort path. GPT-5.6 models now emit reasoning.effort for low/medium/high/xhigh, with max mapped to the xhigh wire value.

Preserve the Responses API reasoning.effort through the OpenAI intermediate by copying it to reasoning_effort before the field is dropped. Skip legacy thinking_mode prompt tags when a supported native GPT effort is emitted, while keeping the legacy fallback for unsupported values (auto/minimal/ultra) and explicit disable semantics (none/off/disabled). Claude adaptive effort continues to use thinking plus output_config.effort.
This commit is contained in:
Edison42
2026-07-20 11:11:37 +07:00
parent d587b2a487
commit cef5dd4d61
7 changed files with 193 additions and 35 deletions
+82 -24
View File
@@ -316,42 +316,100 @@ describe("openaiToKiroRequest", () => {
});
});
it("maps GPT-5.6 reasoning.effort high to Kiro CLI reasoning fields", () => {
it.each([
["high", "gpt-5.6-sol"],
["medium", "kiro/gpt-5.6-terra"],
["low", "gpt-5.6-luna"],
])("maps GPT-5.6 reasoning.effort %s without legacy prompt tags", (effort, model) => {
const body = {
reasoning: { effort: "high" },
messages: [{ role: "user", content: "Think deeply" }]
reasoning: { effort },
messages: [{ role: "user", content: "Use the requested effort" }]
};
const result = openaiToKiroRequest(model, body, true, {});
expect(result.additionalModelRequestFields).toEqual({
reasoning: { effort },
});
expect(systemPromptOf(result)).not.toContain("<thinking_mode>");
expect(systemPromptOf(result)).not.toContain("<max_thinking_length>");
expect(contentOf(result)).not.toContain("<thinking_mode>");
expect(contentOf(result)).not.toContain("<max_thinking_length>");
});
it.each([
["xhigh", "gpt-5.6-terra", "xhigh"],
["max", "gpt-5.6-sol", "xhigh"],
])("preserves GPT-5.6 effort %s as supported wire effort %s", (effort, model, wireEffort) => {
const body = {
reasoning: { effort },
messages: [{ role: "user", content: "Use extended effort" }]
};
const result = openaiToKiroRequest(model, body, true, {});
expect(result.additionalModelRequestFields).toEqual({
reasoning: { effort: wireEffort },
});
expect(systemPromptOf(result)).not.toContain("<thinking_mode>");
expect(systemPromptOf(result)).not.toContain("<max_thinking_length>");
});
it("omits GPT-5.6 effort fields and legacy prompt tags when effort is absent", () => {
const body = {
messages: [{ role: "user", content: "No explicit reasoning effort" }]
};
const result = openaiToKiroRequest("gpt-5.6-sol", body, true, {});
expect(systemPromptOf(result)).toContain("<max_thinking_length>24576</max_thinking_length>");
expect(result.additionalModelRequestFields).toEqual({
reasoning: { effort: "high" },
});
expect(result.additionalModelRequestFields).toBeUndefined();
expect(systemPromptOf(result)).not.toContain("<thinking_mode>");
expect(systemPromptOf(result)).not.toContain("<max_thinking_length>");
});
it("maps prefixed GPT-5.6 reasoning_effort medium to Kiro CLI reasoning fields", () => {
it.each(["auto", "minimal", "ultra"])(
"keeps the legacy thinking fallback for unsupported GPT-5.6 effort %s",
(effort) => {
const body = {
reasoning: { effort },
messages: [{ role: "user", content: "Use legacy thinking" }]
};
const result = openaiToKiroRequest("gpt-5.6-luna", body, true, {});
expect(result.additionalModelRequestFields).toBeUndefined();
expect(systemPromptOf(result)).toContain("<thinking_mode>enabled</thinking_mode>");
expect(systemPromptOf(result)).toContain("<max_thinking_length>");
}
);
it.each(["none", "off", "disabled"])(
"keeps GPT-5.6 reasoning intentionally disabled for effort %s",
(effort) => {
const body = {
reasoning: { effort },
messages: [{ role: "user", content: "Do not reason" }]
};
const result = openaiToKiroRequest("gpt-5.6-luna", body, true, {});
expect(result.additionalModelRequestFields).toBeUndefined();
expect(systemPromptOf(result)).not.toContain("<thinking_mode>");
expect(systemPromptOf(result)).not.toContain("<max_thinking_length>");
}
);
it("keeps the thinking-alias fallback when GPT effort is blank", () => {
const body = {
reasoning_effort: "medium",
messages: [{ role: "user", content: "Think normally" }]
reasoning: { effort: "" },
messages: [{ role: "user", content: "Use the thinking alias" }]
};
const result = openaiToKiroRequest("kiro/gpt-5.6-terra", body, true, {});
expect(result.additionalModelRequestFields).toEqual({
reasoning: { effort: "medium" },
});
});
it("does not forward unsupported GPT-5.6 effort values", () => {
const body = {
reasoning: { effort: "ultra" },
messages: [{ role: "user", content: "Unknown effort" }]
};
const result = openaiToKiroRequest("gpt-5.6-luna", body, true, {});
const result = openaiToKiroRequest("gpt-5.6-sol-thinking", body, true, {});
expect(result.additionalModelRequestFields).toBeUndefined();
expect(systemPromptOf(result)).toContain("<thinking_mode>enabled</thinking_mode>");
expect(systemPromptOf(result)).toContain("<max_thinking_length>");
});
it("does not send additionalModelRequestFields for legacy Kiro model ids", () => {