Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

CodexProvider.test.ts

165 lines4.6 KB

1import { assert, it } from "@effect/vitest";
2​
3import {
4 applyPreferredCodexDefaultModel,
5 isLegacyCodexModel,
6 mapCodexModelCapabilities,
7} from "./CodexProvider.ts";
8​
9it("keeps only the GPT-5.6 Codex family out of legacy models", () => {
10 assert.deepStrictEqual(
11 ["gpt-5.6-luna", "gpt-5.6-terra", "gpt-5.6-sol", "gpt-5.4"].map((model) => [
12 model,
13 isLegacyCodexModel(model),
14 ]),
15 [
16 ["gpt-5.6-luna", false],
17 ["gpt-5.6-terra", false],
18 ["gpt-5.6-sol", false],
19 ["gpt-5.4", true],
20 ],
21 );
22});
23​
24it("maps current Codex model capability fields", () => {
25 const capabilities = mapCodexModelCapabilities({
26 additionalSpeedTiers: [],
27 defaultReasoningEffort: "super-high",
28 description: "Test model",
29 displayName: "GPT Test",
30 hidden: false,
31 id: "gpt-test",
32 isDefault: true,
33 model: "gpt-test",
34 defaultServiceTier: "flex",
35 serviceTiers: [
36 {
37 id: "priority",
38 name: "Fast",
39 description: "Lower latency responses.",
40 },
41 {
42 id: "flex",
43 name: "Flex",
44 description: "Lower-cost asynchronous routing.",
45 },
46 ],
47 supportedReasoningEfforts: [
48 {
49 description: "Maximum reasoning",
50 reasoningEffort: "super-high",
51 },
52 ],
53 });
54​
55 assert.deepStrictEqual(capabilities.optionDescriptors, [
56 {
57 id: "reasoningEffort",
58 label: "Reasoning",
59 type: "select",
60 options: [{ id: "super-high", label: "super-high", isDefault: true }],
61 currentValue: "super-high",
62 },
63 {
64 id: "serviceTier",
65 label: "Service Tier",
66 type: "select",
67 options: [
68 { id: "default", label: "Standard" },
69 {
70 id: "priority",
71 label: "Fast",
72 description: "Lower latency responses.",
73 },
74 {
75 id: "flex",
76 label: "Flex",
77 description: "Lower-cost asynchronous routing.",
78 isDefault: true,
79 },
80 ],
81 currentValue: "flex",
82 },
83 ]);
84});
85​
86it("uses standard routing when the catalog has no default service tier", () => {
87 const capabilities = mapCodexModelCapabilities({
88 additionalSpeedTiers: ["fast"],
89 defaultReasoningEffort: "medium",
90 defaultServiceTier: null,
91 description: "Test model",
92 displayName: "GPT Test",
93 hidden: false,
94 id: "gpt-test",
95 isDefault: true,
96 model: "gpt-test",
97 serviceTiers: [
98 {
99 id: "priority",
100 name: "Fast",
101 description: "1.5x speed, increased usage",
102 },
103 ],
104 supportedReasoningEfforts: [],
105 });
106​
107 assert.deepStrictEqual(capabilities.optionDescriptors, [
108 {
109 id: "serviceTier",
110 label: "Service Tier",
111 type: "select",
112 options: [
113 { id: "default", label: "Standard", isDefault: true },
114 {
115 id: "priority",
116 label: "Fast",
117 description: "1.5x speed, increased usage",
118 },
119 ],
120 currentValue: "default",
121 },
122 ]);
123});
124​
125it("marks the most preferred available model as default", () => {
126 const models = applyPreferredCodexDefaultModel([
127 { slug: "gpt-5.6-terra", name: "GPT-5.6-Terra", isCustom: false, capabilities: null },
128 { slug: "gpt-5.4", name: "GPT-5.4", isCustom: false, isDefault: true, capabilities: null },
129 ]);
130​
131 assert.deepStrictEqual(
132 models.map((model) => ({ slug: model.slug, isDefault: model.isDefault })),
133 [
134 { slug: "gpt-5.6-terra", isDefault: true },
135 { slug: "gpt-5.4", isDefault: undefined },
136 ],
137 );
138});
139​
140it("prefers sol over terra when both are available", () => {
141 const models = applyPreferredCodexDefaultModel([
142 { slug: "gpt-5.6-terra", name: "GPT-5.6-Terra", isCustom: false, capabilities: null },
143 { slug: "gpt-5.6-sol", name: "GPT-5.6-Sol", isCustom: false, capabilities: null },
144 ]);
145​
146 assert.deepStrictEqual(models.find((model) => model.isDefault)?.slug, "gpt-5.6-sol");
147});
148​
149it("keeps Codex's own default when no preferred model is available", () => {
150 const models = applyPreferredCodexDefaultModel([
151 { slug: "gpt-5.5", name: "GPT-5.5", isCustom: false, capabilities: null },
152 { slug: "gpt-5.4", name: "GPT-5.4", isCustom: false, isDefault: true, capabilities: null },
153 ]);
154​
155 assert.deepStrictEqual(models.find((model) => model.isDefault)?.slug, "gpt-5.4");
156});
157​
158it("ignores custom models that shadow a preferred slug", () => {
159 const models = applyPreferredCodexDefaultModel([
160 { slug: "gpt-5.6-sol", name: "gpt-5.6-sol", isCustom: true, capabilities: null },
161 { slug: "gpt-5.4", name: "GPT-5.4", isCustom: false, isDefault: true, capabilities: null },
162 ]);
163​
164 assert.deepStrictEqual(models.find((model) => model.isDefault)?.slug, "gpt-5.4");
165});