@devries-cameron20 / t3code Mirror · read-only / commits / fba1997db4
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, 03:15 UTC

fix(server): Codex titles no longer fail on ChatGPT accounts without gpt-6-luna (#30078)

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

Muzammil Hussain committed Nov 6, 2026 at 09:22 UTC fba1997db4438ff2cd3fea72751af07be35f8b51
2 files changed +109 -15
apps/server/src/textGeneration/CodexTextGeneration.test.ts
+84 -9
@@ -163,6 +163,8 @@ function withFakeCodexEnv<A, E, R>(
163 launchArgs?: string;
164 environment?: NodeJS.ProcessEnv;
165 models?: ReadonlyArray<string>;
166 + defaultModel?: string;
167 + customModels?: ReadonlyArray<string>;
168 managedRuntime?: boolean;
169 },
170 effectFn: (textGeneration: TextGeneration.TextGeneration["Service"]) => Effect.Effect<A, E, R>,
@@ -171,7 +173,11 @@ function withFakeCodexEnv<A, E, R>(
173 const fs = yield* FileSystem.FileSystem;
174 const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3code-codex-text-" });
175 const codexPath = yield* makeFakeCodexBinary(tempDir, input);
174 - const config = decodeCodexSettings({ binaryPath: codexPath, launchArgs: input.launchArgs });
176 + const config = decodeCodexSettings({
177 + binaryPath: codexPath,
178 + launchArgs: input.launchArgs,
179 + customModels: input.customModels,
180 + });
181 const textGeneration = yield* makeCodexTextGeneration(
182 config,
183 input.environment === undefined ? undefined : { ...process.env, ...input.environment },
@@ -180,6 +186,7 @@ function withFakeCodexEnv<A, E, R>(
186 slug,
187 name: slug,
188 isCustom: false,
189 + ...(slug === input.defaultModel ? { isDefault: true } : {}),
190 capabilities: null,
191 })),
192 ),
@@ -224,15 +231,40 @@ it.layer(layerCodexTextGenerationTest)("CodexTextGeneration", (it) => {
231 }),
232 );
233
227 - it.effect.each(["gpt-5.6-luna", "openai.gpt-5.6-luna"])(
228 - "dispatches the qualified live model for %s",
229 - (selectedModel) =>
234 + it.effect.each([
235 + {
236 + selectedModel: "gpt-5.6-luna",
237 + models: ["openai.gpt-5.6-luna"],
238 + expected: "openai.gpt-5.6-luna",
239 + },
240 + {
241 + selectedModel: "openai.gpt-5.6-luna",
242 + models: ["openai.gpt-5.6-luna"],
243 + expected: "openai.gpt-5.6-luna",
244 + },
245 + {
246 + selectedModel: "openai.gpt-5.6-luna",
247 + models: ["gpt-6-astra", "gpt-5.6-luna"],
248 + defaultModel: "gpt-6-astra",
249 + expected: "gpt-5.6-luna",
250 + },
251 + {
252 + selectedModel: "gpt-6-luna",
253 + models: ["gpt-5.6-luna", "gpt-6-astra"],
254 + defaultModel: "gpt-6-astra",
255 + expected: "gpt-6-astra",
256 + },
257 + { selectedModel: "gpt-6-luna", models: ["gpt-5.6-luna"], expected: "gpt-5.6-luna" },
258 + { selectedModel: "gpt-6-luna", models: [], expected: "gpt-6-luna" },
259 + ])(
260 + "dispatches $expected for $selectedModel from $models",
261 + ({ selectedModel, models, defaultModel, expected }) =>
262 withFakeCodexEnv(
263 {
232 - output: JSON.stringify({ title: "Bedrock title" }),
233 - models: ["openai.gpt-5.6-luna"],
234 - requireArg: "--model openai.gpt-5.6-luna",
235 - forbidArg: "--model gpt-5.6-luna",
264 + output: JSON.stringify({ title: "Live title" }),
265 + models,
266 + ...(defaultModel ? { defaultModel } : {}),
267 + requireArg: `--model ${expected}`,
268 },
269 (textGeneration) =>
270 Effect.gen(function* () {
@@ -241,11 +273,54 @@ it.layer(layerCodexTextGenerationTest)("CodexTextGeneration", (it) => {
273 message: "Describe this change",
274 modelSelection: createModelSelection(ProviderInstanceId.make("codex"), selectedModel),
275 });
244 - expect(result.title).toBe("Bedrock title");
276 + expect(result.title).toBe("Live title");
277 }),
278 ),
279 );
280
281 + it.effect("drops the requested model's options when falling back to another model", () =>
282 + withFakeCodexEnv(
283 + {
284 + output: JSON.stringify({ title: "Live title" }),
285 + models: ["gpt-6-astra"],
286 + requireArg: '--model gpt-6-astra --config model_reasoning_effort="low"',
287 + forbidArg: 'service_tier="priority"',
288 + },
289 + (textGeneration) =>
290 + textGeneration.generateThreadTitle({
291 + cwd: process.cwd(),
292 + message: "Describe this change",
293 + modelSelection: createModelSelection(ProviderInstanceId.make("codex"), "gpt-6-luna", [
294 + { id: "reasoningEffort", value: "none" },
295 + { id: "serviceTier", value: "priority" },
296 + ]),
297 + }),
298 + ),
299 + );
300 +
301 + it.effect("sends a configured custom model the managed snapshot leaves out", () =>
302 + withFakeCodexEnv(
303 + {
304 + output: JSON.stringify({ title: "Live title" }),
305 + models: ["gpt-6-astra", "gpt-5.6-luna"],
306 + defaultModel: "gpt-6-astra",
307 + customModels: ["gpt-5.6-luna-preview"],
308 + managedRuntime: true,
309 + requireArg: '--model gpt-5.6-luna-preview --config model_reasoning_effort="high"',
310 + },
311 + (textGeneration) =>
312 + textGeneration.generateThreadTitle({
313 + cwd: process.cwd(),
314 + message: "Describe this change",
315 + modelSelection: createModelSelection(
316 + ProviderInstanceId.make("codex"),
317 + "gpt-5.6-luna-preview",
318 + [{ id: "reasoningEffort", value: "high" }],
319 + ),
320 + }),
321 + ),
322 + );
323 +
324 it.effect("omits a persisted service tier for managed ChatGPT text generation", () =>
325 withFakeCodexEnv(
326 {
apps/server/src/textGeneration/CodexTextGeneration.ts
+25 -6
@@ -24,7 +24,11 @@ import {
24 normalizeCliError,
25 toJsonSchemaObject,
26 } from "@t3tools/provider-core/server/textGenerationUtils";
27 -import { codexModelFamily, getModelSelectionStringOptionValue } from "@t3tools/shared/model";
27 +import {
28 + codexModelFamily,
29 + getModelSelectionStringOptionValue,
30 + readCustomModelEntries,
31 +} from "@t3tools/shared/model";
32 import { getCodexServiceTierOptionValue } from "../codexModelOptions.ts";
33 import * as HostProcess from "@t3tools/shared/HostProcess";
34
@@ -245,17 +249,32 @@ export const makeCodexTextGeneration = Effect.fn("makeCodexTextGeneration")(func
249 const effectiveEnvironment = resolved?.environment ?? resolvedEnvironment;
250 const models = yield* getModels;
251 const requestedModel = modelSelection.model;
248 - const model =
252 + const listed = models.filter((candidate) => !candidate.isCustom);
253 + // An unlisted slug is one this account can't run, e.g. gpt-6-luna on a ChatGPT login.
254 + const requestedFamily = codexModelFamily(requestedModel);
255 + const matchedModel =
256 models.find((candidate) => candidate.slug === requestedModel)?.slug ??
250 - models.find(
251 - (candidate) => !candidate.isCustom && codexModelFamily(candidate.slug) === requestedModel,
257 + // Managed snapshots omit configured custom models; send those as requested.
258 + readCustomModelEntries(codexConfig.customModels).find(
259 + (entry) => entry.slug === requestedModel,
260 )?.slug ??
261 + listed.find((candidate) => codexModelFamily(candidate.slug) === requestedFamily)?.slug;
262 + const model =
263 + matchedModel ??
264 + listed.find((candidate) => candidate.isDefault)?.slug ??
265 + listed.find((candidate) => !candidate.isLegacy)?.slug ??
266 + listed[0]?.slug ??
267 requestedModel;
268 + // The selection's options were chosen for the requested model and may not fit a fallback.
269 + const fellBack = matchedModel === undefined && model !== requestedModel;
270 const launchArgs = resolveCodexLaunchArgs(effectiveConfig.launchArgs, effectiveEnvironment);
271 const reasoningEffort =
256 - getModelSelectionStringOptionValue(modelSelection, "reasoningEffort") ??
272 + (fellBack
273 + ? undefined
274 + : getModelSelectionStringOptionValue(modelSelection, "reasoningEffort")) ??
275 DEFAULT_TEXT_GENERATION_REASONING_EFFORT;
258 - const serviceTier = resolved ? undefined : getCodexServiceTierOptionValue(modelSelection);
276 + const serviceTier =
277 + resolved || fellBack ? undefined : getCodexServiceTierOptionValue(modelSelection);
278 const binary = effectiveConfig.binaryPath || "codex";
279 const env = {
280 ...effectiveEnvironment,