@devries-cameron20 / t3code Mirror · read-only / commits / bed62e60b4
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 10:45 UTC

fix(server): ChatGPT-connected Codex shows reasoning for models newer than its CLI (#27931)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Theo Browne committed Oct 30, 2026 at 18:54 UTC bed62e60b42a13ae4b0de3b32baa5fda9bed95e8
2 files changed +85 -16
apps/server/src/provider/CodexChatGptModels.test.ts
+46 -5
@@ -19,11 +19,40 @@ it.effect(
19 models:
20 request.headers.authorization === "Bearer account-a"
21 ? [
22 - { slug: "second", display_name: "Second from OpenAI", visibility: "list" },
23 - { slug: "hidden", display_name: "Hidden", visibility: "hidden" },
24 - { slug: "first", display_name: "First from OpenAI", visibility: "list" },
22 + {
23 + slug: "second",
24 + display_name: "Second from OpenAI",
25 + visibility: "list",
26 + default_reasoning_level: "low",
27 + supported_reasoning_levels: [
28 + { effort: "low", description: "Fast" },
29 + { effort: "high", description: "Deep" },
30 + ],
31 + },
32 + {
33 + slug: "hidden",
34 + display_name: "Hidden",
35 + visibility: "hidden",
36 + default_reasoning_level: null,
37 + supported_reasoning_levels: null,
38 + },
39 + {
40 + slug: "first",
41 + display_name: "First from OpenAI",
42 + visibility: "list",
43 + default_reasoning_level: "high",
44 + supported_reasoning_levels: [{ effort: "high", description: "Deep" }],
45 + },
46 ]
26 - : [{ slug: "account-b-only", display_name: "B", visibility: "list" }],
47 + : [
48 + {
49 + slug: "account-b-only",
50 + display_name: "B",
51 + visibility: "list",
52 + default_reasoning_level: null,
53 + supported_reasoning_levels: null,
54 + },
55 + ],
56 }),
57 ),
58 );
@@ -49,7 +78,18 @@ it.effect(
78 ],
79 );
80 assert.deepEqual(a[1]!.capabilities, native[0]!.capabilities);
52 - assert.isNull(a[0]!.capabilities);
81 + assert.deepEqual(a[0]!.capabilities?.optionDescriptors, [
82 + {
83 + id: "reasoningEffort",
84 + label: "Reasoning",
85 + type: "select",
86 + options: [
87 + { id: "low", label: "Low", isDefault: true },
88 + { id: "high", label: "High" },
89 + ],
90 + currentValue: "low",
91 + },
92 + ]);
93 const b = yield* chatGptModels("account-b", native).pipe(
94 Effect.provideService(HttpClient.HttpClient, http),
95 );
@@ -57,6 +97,7 @@ it.effect(
97 b.map((model) => model.slug),
98 ["account-b-only"],
99 );
100 + assert.isNull(b[0]!.capabilities);
101 assert.deepEqual(requests, ["Bearer account-a", "Bearer account-b"]);
102 }),
103 );
apps/server/src/provider/CodexChatGptModels.ts
+39 -11
@@ -2,6 +2,7 @@ import type { ServerProviderModel } from "@t3tools/contracts";
2 import * as Effect from "effect/Effect";
3 import * as Schema from "effect/Schema";
4 import { HttpClient, HttpClientRequest } from "effect/http";
5 +import { mapCodexModelCapabilities } from "./CodexProvider.ts";
6
7 export class ChatGptCatalogError extends Schema.TaggedError<ChatGptCatalogError>()(
8 "ChatGptCatalogError",
@@ -14,6 +15,17 @@ const Catalog = Schema.Struct({
15 slug: Schema.NonEmptyString,
16 display_name: Schema.NonEmptyString,
17 visibility: Schema.String,
18 + default_reasoning_level: Schema.optionalKey(Schema.NullOr(Schema.NonEmptyString)),
19 + supported_reasoning_levels: Schema.optionalKey(
20 + Schema.NullOr(
21 + Schema.Array(
22 + Schema.Struct({
23 + effort: Schema.NonEmptyString,
24 + description: Schema.optionalKey(Schema.NullOr(Schema.String)),
25 + }),
26 + ),
27 + ),
28 + ),
29 }),
30 ),
31 });
@@ -32,15 +44,31 @@ export const chatGptModels = Effect.fn("chatGptModels")(function* (
44 const catalog = yield* response.json.pipe(Effect.flatMap(Schema.decodeUnknownEffect(Catalog)));
45 return catalog.models
46 .filter((model) => model.visibility === "list")
35 - .map(
36 - (model) =>
37 - ({
38 - ...nativeModels.find((native) => native.slug === model.slug),
39 - capabilities:
40 - nativeModels.find((native) => native.slug === model.slug)?.capabilities ?? null,
41 - slug: model.slug,
42 - name: model.display_name,
43 - isCustom: false,
44 - }) satisfies ServerProviderModel,
45 - );
47 + .map((model): ServerProviderModel => {
48 + const native = nativeModels.find((candidate) => candidate.slug === model.slug);
49 + // A pinned Codex CLI can predate a model the account already has; the catalog still lists its efforts.
50 + const catalogCapabilities =
51 + model.default_reasoning_level && model.supported_reasoning_levels
52 + ? mapCodexModelCapabilities({
53 + id: model.slug,
54 + model: model.slug,
55 + displayName: model.display_name,
56 + description: "",
57 + hidden: false,
58 + isDefault: false,
59 + defaultReasoningEffort: model.default_reasoning_level,
60 + supportedReasoningEfforts: model.supported_reasoning_levels.map((level) => ({
61 + reasoningEffort: level.effort,
62 + description: level.description ?? "",
63 + })),
64 + })
65 + : null;
66 + return {
67 + ...native,
68 + capabilities: native?.capabilities ?? catalogCapabilities,
69 + slug: model.slug,
70 + name: model.display_name,
71 + isCustom: false,
72 + };
73 + });
74 }, Effect.timeout("15 seconds"));