mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
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:
@@ -5,8 +5,34 @@ import { translateRequest } from "../../open-sse/translator/index.js";
|
||||
import { FORMATS } from "../../open-sse/translator/formats.js";
|
||||
|
||||
const O2K = (body) => translateRequest(FORMATS.OPENAI, FORMATS.KIRO, "m", body, true, null, "kiro");
|
||||
const R2K = (model, body) => translateRequest(
|
||||
FORMATS.OPENAI_RESPONSES,
|
||||
FORMATS.KIRO,
|
||||
model,
|
||||
body,
|
||||
true,
|
||||
null,
|
||||
"kiro"
|
||||
);
|
||||
|
||||
describe("OpenAI → Kiro", () => {
|
||||
it.each([
|
||||
["high", "gpt-5.6-sol"],
|
||||
["medium", "gpt-5.6-terra"],
|
||||
["low", "gpt-5.6-luna"],
|
||||
])("preserves Responses reasoning.effort %s through the full Kiro route", (effort, model) => {
|
||||
const out = R2K(model, {
|
||||
input: "Use the requested effort",
|
||||
reasoning: { effort },
|
||||
});
|
||||
|
||||
expect(out.additionalModelRequestFields).toEqual({
|
||||
reasoning: { effort },
|
||||
});
|
||||
expect(out.systemPrompt || "").not.toContain("<thinking_mode>");
|
||||
expect(out.systemPrompt || "").not.toContain("<max_thinking_length>");
|
||||
});
|
||||
|
||||
// openai-to-kiro.js — safeJSONParse guards bad tool-call JSON (fixed in PR #1582)
|
||||
it("malformed tool arguments do not throw the whole request", () => {
|
||||
expect(() =>
|
||||
|
||||
@@ -112,12 +112,54 @@ describe("Claude → Kiro (direct route)", () => {
|
||||
expect(out.systemPrompt).toContain("<max_thinking_length>24576</max_thinking_length>");
|
||||
});
|
||||
|
||||
it("maps Claude-format effort to GPT-5.6 Kiro CLI reasoning fields", () => {
|
||||
it("maps Claude-format effort to GPT-5.6 reasoning fields without legacy prompt tags", () => {
|
||||
const out = C2K({
|
||||
output_config: { effort: "low" },
|
||||
messages: [{ role: "user", content: "think lightly" }],
|
||||
}, null, "gpt-5.6-sol");
|
||||
|
||||
expect(out.additionalModelRequestFields).toEqual({
|
||||
reasoning: { effort: "low" },
|
||||
});
|
||||
expect(out.systemPrompt || "").not.toContain("<thinking_mode>");
|
||||
expect(out.systemPrompt || "").not.toContain("<max_thinking_length>");
|
||||
});
|
||||
|
||||
it.each(["auto", "minimal", "ultra"])(
|
||||
"keeps the legacy thinking fallback for unsupported GPT-5.6 effort %s",
|
||||
(effort) => {
|
||||
const out = C2K({
|
||||
output_config: { effort },
|
||||
messages: [{ role: "user", content: "Use legacy thinking" }],
|
||||
}, null, "gpt-5.6-sol");
|
||||
|
||||
expect(out.additionalModelRequestFields).toBeUndefined();
|
||||
expect(out.systemPrompt).toContain("<thinking_mode>enabled</thinking_mode>");
|
||||
expect(out.systemPrompt).toContain("<max_thinking_length>");
|
||||
}
|
||||
);
|
||||
|
||||
it.each(["none", "off", "disabled"])(
|
||||
"keeps GPT-5.6 reasoning intentionally disabled for effort %s",
|
||||
(effort) => {
|
||||
const out = C2K({
|
||||
output_config: { effort },
|
||||
messages: [{ role: "user", content: "Do not reason" }],
|
||||
}, null, "gpt-5.6-sol");
|
||||
|
||||
expect(out.additionalModelRequestFields).toBeUndefined();
|
||||
expect(out.systemPrompt || "").not.toContain("<thinking_mode>");
|
||||
expect(out.systemPrompt || "").not.toContain("<max_thinking_length>");
|
||||
}
|
||||
);
|
||||
|
||||
it("keeps explicit Claude effort ahead of an injected OpenAI effort", () => {
|
||||
const out = C2K({
|
||||
output_config: { effort: "low" },
|
||||
reasoning_effort: "high",
|
||||
messages: [{ role: "user", content: "honor the client effort" }],
|
||||
}, null, "gpt-5.6-sol");
|
||||
|
||||
expect(out.additionalModelRequestFields).toEqual({
|
||||
reasoning: { effort: "low" },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user