feat(codex): support GPT-5.6 Max and Ultra overrides
Add "ultra" reasoning level for Codex GPT-5.6 Sol and Terra, and expose Max for Luna (Luna falls back Ultra to Max since it is not supported upstream). Scoped to cx/ routes only; Kiro and generic OpenAI routing unchanged.
This commit is contained in:
@@ -69,3 +69,33 @@ describe("Codex fast tier and capacity handling", () => {
|
||||
await expect(new Response(peek.replacementBody).text()).resolves.toBe(text);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Codex reasoning normalization", () => {
|
||||
it.each([
|
||||
["gpt-5.6-sol", "max", "max"],
|
||||
["gpt-5.6-sol", "ultra", "ultra"],
|
||||
["gpt-5.6-terra", "max", "max"],
|
||||
["gpt-5.6-terra", "ultra", "ultra"],
|
||||
["gpt-5.6-luna", "max", "max"],
|
||||
["gpt-5.6-luna", "ultra", "max"],
|
||||
])("normalizes %s effort %s to %s", (model, effort, expected) => {
|
||||
const body = new CodexExecutor().transformRequest(model, {
|
||||
model,
|
||||
input: "hi",
|
||||
reasoning: { effort },
|
||||
}, true, {});
|
||||
|
||||
expect(body.reasoning.effort).toBe(expected);
|
||||
});
|
||||
|
||||
it("resolves review models before applying the reasoning matrix", () => {
|
||||
const body = new CodexExecutor().transformRequest("gpt-5.6-terra-review", {
|
||||
model: "gpt-5.6-terra-review",
|
||||
input: "hi",
|
||||
reasoning_effort: "ultra",
|
||||
}, true, {});
|
||||
|
||||
expect(body.model).toBe("gpt-5.6-terra");
|
||||
expect(body.reasoning.effort).toBe("ultra");
|
||||
});
|
||||
});
|
||||
|
||||
111
tests/unit/codex-native-passthrough-thinking.test.js
Normal file
111
tests/unit/codex-native-passthrough-thinking.test.js
Normal file
@@ -0,0 +1,111 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const { executeMock, forcedSSEToJsonMock } = vi.hoisted(() => ({
|
||||
executeMock: vi.fn(),
|
||||
forcedSSEToJsonMock: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("../../open-sse/executors/index.js", () => ({
|
||||
getExecutor: () => ({
|
||||
noAuth: true,
|
||||
execute: executeMock,
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("../../open-sse/utils/requestLogger.js", () => ({
|
||||
createRequestLogger: async () => ({
|
||||
logClientRawRequest: vi.fn(),
|
||||
logRawRequest: vi.fn(),
|
||||
logTargetRequest: vi.fn(),
|
||||
logProviderResponse: vi.fn(),
|
||||
logConvertedResponse: vi.fn(),
|
||||
logError: vi.fn(),
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("@/lib/usageDb.js", () => ({
|
||||
trackPendingRequest: vi.fn(),
|
||||
appendRequestLog: vi.fn(async () => {}),
|
||||
saveRequestDetail: vi.fn(async () => {}),
|
||||
}));
|
||||
|
||||
vi.mock("../../open-sse/handlers/chatCore/sseToJsonHandler.js", () => ({
|
||||
handleForcedSSEToJson: forcedSSEToJsonMock,
|
||||
}));
|
||||
|
||||
const { handleChatCore } = await import("../../open-sse/handlers/chatCore.js");
|
||||
|
||||
async function runNativeCodexRequest(model, reasoning) {
|
||||
const body = {
|
||||
model,
|
||||
input: "hello",
|
||||
stream: false,
|
||||
...(reasoning ? { reasoning } : {}),
|
||||
};
|
||||
|
||||
await handleChatCore({
|
||||
body,
|
||||
modelInfo: { provider: "codex", model },
|
||||
credentials: { accessToken: "test-token", providerSpecificData: {} },
|
||||
log: { debug: vi.fn(), info: vi.fn(), warn: vi.fn() },
|
||||
connectionId: "test-connection",
|
||||
rtkEnabled: false,
|
||||
headroomEnabled: false,
|
||||
cavemanEnabled: false,
|
||||
ponytailEnabled: false,
|
||||
pxpipeEnabled: false,
|
||||
sourceFormatOverride: "openai-responses",
|
||||
clientRawRequest: {
|
||||
endpoint: "/v1/responses",
|
||||
body,
|
||||
headers: {
|
||||
accept: "application/json",
|
||||
"user-agent": "codex-cli/0.144.1",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return executeMock.mock.calls.at(-1)[0].body;
|
||||
}
|
||||
|
||||
describe("native Codex passthrough thinking suffixes", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
executeMock.mockResolvedValue({
|
||||
response: new Response("", { status: 200 }),
|
||||
url: "https://chatgpt.com/backend-api/codex/responses",
|
||||
headers: {},
|
||||
transformedBody: null,
|
||||
});
|
||||
forcedSSEToJsonMock.mockResolvedValue({
|
||||
success: true,
|
||||
response: new Response("{}", { status: 200 }),
|
||||
});
|
||||
});
|
||||
|
||||
it("forwards Ultra for Sol", async () => {
|
||||
const body = await runNativeCodexRequest("gpt-5.6-sol(ultra)");
|
||||
|
||||
expect(body.model).toBe("gpt-5.6-sol");
|
||||
expect(body.reasoning).toEqual({ effort: "ultra" });
|
||||
});
|
||||
|
||||
it("converts unsupported Luna Ultra to Max without dropping reasoning metadata", async () => {
|
||||
const body = await runNativeCodexRequest("gpt-5.6-luna(ultra)", {
|
||||
effort: "low",
|
||||
summary: "detailed",
|
||||
});
|
||||
|
||||
expect(body.model).toBe("gpt-5.6-luna");
|
||||
expect(body.reasoning).toEqual({ effort: "max", summary: "detailed" });
|
||||
});
|
||||
|
||||
it("forwards Ultra through a Terra review alias", async () => {
|
||||
const body = await runNativeCodexRequest("gpt-5.6-terra-review(ultra)", {
|
||||
effort: "low",
|
||||
});
|
||||
|
||||
expect(body.model).toBe("gpt-5.6-terra");
|
||||
expect(body.reasoning).toEqual({ effort: "ultra" });
|
||||
});
|
||||
});
|
||||
@@ -2,11 +2,21 @@ import { describe, it, expect } from "vitest";
|
||||
import { getThinkingLevels } from "../../open-sse/providers/thinkingLevels.js";
|
||||
|
||||
describe("getThinkingLevels", () => {
|
||||
it("adds max for gpt-5.6-sol on codex", () => {
|
||||
const levels = getThinkingLevels("codex", "gpt-5.6-sol");
|
||||
expect(levels).toContain("max");
|
||||
expect(levels).toContain("xhigh");
|
||||
expect(levels).not.toContain("ultra");
|
||||
it.each([
|
||||
["gpt-5.6-sol", ["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"]],
|
||||
["gpt-5.6-terra", ["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"]],
|
||||
["gpt-5.6-luna", ["none", "minimal", "low", "medium", "high", "xhigh", "max"]],
|
||||
["gpt-5.6-sol-review", ["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"]],
|
||||
["gpt-5.6-terra-review", ["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"]],
|
||||
["gpt-5.6-luna-review", ["none", "minimal", "low", "medium", "high", "xhigh", "max"]],
|
||||
])("returns Codex levels for %s", (model, expected) => {
|
||||
expect(getThinkingLevels("codex", model)).toEqual(expected);
|
||||
});
|
||||
|
||||
it("does not expose Codex-only GPT-5.6 overrides on Kiro", () => {
|
||||
expect(getThinkingLevels("kiro", "gpt-5.6-sol")).toEqual([
|
||||
"none", "minimal", "low", "medium", "high", "xhigh",
|
||||
]);
|
||||
});
|
||||
|
||||
it("does not add max for other codex models", () => {
|
||||
@@ -14,7 +24,7 @@ describe("getThinkingLevels", () => {
|
||||
expect(levels).toEqual(["low", "medium", "high", "xhigh"]);
|
||||
});
|
||||
|
||||
it("does not add max for other gpt-5.6 models", () => {
|
||||
it("does not add max for other Codex models", () => {
|
||||
const levels = getThinkingLevels("codex", "gpt-5.5");
|
||||
expect(levels || []).not.toContain("max");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user