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

CodexProvider.test.ts

163 lines4.7 KB

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