gpt-5-6-max-thinking.test.ts 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import { describe, expect, it } from "vitest";
  2. import { clampThinkingLevel, getModel, getModels, getSupportedThinkingLevels } from "../src/models.ts";
  3. import { streamSimpleOpenAICodexResponses } from "../src/providers/openai-codex-responses.ts";
  4. import type { Context, Model } from "../src/types.ts";
  5. const CODEX_MODELS = ["gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra"] as const;
  6. function mockCodexToken(): string {
  7. const payload = Buffer.from(
  8. JSON.stringify({ "https://api.openai.com/auth": { chatgpt_account_id: "acc_test" } }),
  9. ).toString("base64");
  10. return `header.${payload}.signature`;
  11. }
  12. describe("GPT-5.6 Max thinking", () => {
  13. it.each(CODEX_MODELS)("publishes final Codex metadata for %s", (modelId) => {
  14. const model = getModel("openai-codex", modelId);
  15. expect(model).toMatchObject({
  16. id: modelId,
  17. api: "openai-codex-responses",
  18. provider: "openai-codex",
  19. baseUrl: "https://chatgpt.com/backend-api",
  20. contextWindow: 372000,
  21. maxTokens: 128000,
  22. thinkingLevelMap: { minimal: "low", xhigh: "xhigh", max: "max" },
  23. });
  24. expect(getSupportedThinkingLevels(model)).toEqual(["off", "minimal", "low", "medium", "high", "xhigh", "max"]);
  25. });
  26. it.each(CODEX_MODELS)("publishes final direct OpenAI metadata for %s", (modelId) => {
  27. expect(getModel("openai", modelId)).toMatchObject({
  28. id: modelId,
  29. api: "openai-responses",
  30. provider: "openai",
  31. baseUrl: "https://api.openai.com/v1",
  32. contextWindow: 272000,
  33. maxTokens: 128000,
  34. thinkingLevelMap: { off: "none", xhigh: "xhigh", max: "max" },
  35. });
  36. });
  37. it.each(["openai", "openai-codex"] as const)("does not publish a bare gpt-5.6 alias for %s", (provider) => {
  38. expect(getModels(provider).some((model) => model.id === "gpt-5.6")).toBe(false);
  39. });
  40. it("keeps Max independent from xhigh when clamping", () => {
  41. const ordinary: Model<"openai-completions"> = {
  42. id: "ordinary-reasoning",
  43. name: "Ordinary Reasoning",
  44. api: "openai-completions",
  45. provider: "test",
  46. baseUrl: "https://example.com/v1",
  47. reasoning: true,
  48. input: ["text"],
  49. cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
  50. contextWindow: 128000,
  51. maxTokens: 4096,
  52. };
  53. const maxOnly = { ...ordinary, thinkingLevelMap: { xhigh: null, max: "max" } };
  54. expect(getSupportedThinkingLevels(ordinary)).toEqual(["off", "minimal", "low", "medium", "high"]);
  55. expect(clampThinkingLevel(ordinary, "max")).toBe("high");
  56. expect(getSupportedThinkingLevels(maxOnly)).toEqual(["off", "minimal", "low", "medium", "high", "max"]);
  57. expect(clampThinkingLevel(maxOnly, "xhigh")).toBe("max");
  58. });
  59. it("sends reasoning.effort=max through the Codex adapter", async () => {
  60. const context: Context = {
  61. systemPrompt: "Be concise.",
  62. messages: [{ role: "user", content: "Hello", timestamp: Date.now() }],
  63. };
  64. let payload: unknown;
  65. await streamSimpleOpenAICodexResponses(getModel("openai-codex", "gpt-5.6-sol"), context, {
  66. apiKey: mockCodexToken(),
  67. reasoning: "max",
  68. onPayload: (request) => {
  69. payload = request;
  70. throw new Error("payload captured");
  71. },
  72. }).result();
  73. expect(payload).toMatchObject({ reasoning: { effort: "max", summary: "auto" } });
  74. });
  75. });