The best way to control Claude Code, Codex and more from any computer or phone
fix(server): codex text generation keeps local provider launch args (#32597)
Co-authored-by: Zuri <zurih@rtx.internal> Co-authored-by: maria-rcks <maria@kuuro.net>
Mia's AI Lab committed
Nov 12, 2026 at 01:05 UTC
20b934c8307f9809895db05ddebbf5c165ccdf8c
4 files changed
+79
-17
apps/server/src/provider/codexLaunchArgs.test.ts
+34
-1
@@ -2,7 +2,11 @@ import * as NodeAssert from "node:assert/strict";
2
3
import { describe, it } from "vite-plus/test";
4
5
-import { codexAppServerArgs, codexExecLaunchArgs } from "./codexLaunchArgs.ts";
5
+import {
6
+ codexAppServerArgs,
7
+ codexExecLaunchArgs,
8
+ codexMcpListLaunchArgs,
9
+} from "./codexLaunchArgs.ts";
10
11
describe("codexAppServerArgs", () => {
12
it("preserves escaped TOML quotes in config values", () => {
@@ -27,3 +31,32 @@ describe("codexExecLaunchArgs", () => {
31
]);
32
});
33
});
34
+
35
+describe("codex exec and mcp list launch args", () => {
36
+ const launchArgs =
37
+ "--strict-config --oss --local-provider ollama --profile local -p=work --listen off --enable foo";
38
+
39
+ it("keeps the local model provider flags for codex exec", () => {
40
+ NodeAssert.deepStrictEqual(codexExecLaunchArgs(launchArgs), [
41
+ "--strict-config",
42
+ "--oss",
43
+ "--local-provider",
44
+ "ollama",
45
+ "--profile",
46
+ "local",
47
+ "-p=work",
48
+ "--enable",
49
+ "foo",
50
+ ]);
51
+ });
52
+
53
+ it("keeps the selected profile and drops exec-only flags for codex mcp list", () => {
54
+ NodeAssert.deepStrictEqual(codexMcpListLaunchArgs(launchArgs), [
55
+ "--profile",
56
+ "local",
57
+ "-p=work",
58
+ "--enable",
59
+ "foo",
60
+ ]);
61
+ });
62
+});
apps/server/src/provider/codexLaunchArgs.ts
+36
-9
@@ -14,26 +14,53 @@ export const codexAppServerArgs = (launchArgs?: string) => [
14
...codexLaunchArgv(launchArgs),
15
];
16
17
-export const codexExecLaunchArgs = (launchArgs?: string) => {
17
+interface LaunchArgFilter {
18
+ readonly switches: ReadonlySet<string>;
19
+ readonly valueFlags: ReadonlySet<string>;
20
+ readonly inlinePrefixes: ReadonlyArray<string>;
21
+}
22
+
23
+const SHARED_VALUE_FLAGS = ["--config", "-c", "--enable", "--disable"];
24
+const SHARED_INLINE_PREFIXES = ["--config=", "-c=", "--enable=", "--disable="];
25
+
26
+const MCP_LIST_FILTER: LaunchArgFilter = {
27
+ switches: new Set(),
28
+ valueFlags: new Set([...SHARED_VALUE_FLAGS, "--profile", "-p"]),
29
+ inlinePrefixes: [...SHARED_INLINE_PREFIXES, "--profile=", "-p="],
30
+};
31
+
32
+const EXEC_FILTER: LaunchArgFilter = {
33
+ switches: new Set(["--strict-config", "--oss"]),
34
+ valueFlags: new Set([...SHARED_VALUE_FLAGS, "--local-provider", "--profile", "-p"]),
35
+ inlinePrefixes: [...SHARED_INLINE_PREFIXES, "--local-provider=", "--profile=", "-p="],
36
+};
37
+
38
+const filterLaunchArgs = (launchArgs: string | undefined, allowed: LaunchArgFilter) => {
39
const args = codexLaunchArgv(launchArgs);
19
- const execArgs: Array<string> = [];
40
+ const kept: Array<string> = [];
41
42
for (let index = 0; index < args.length; index++) {
43
const arg = args[index];
44
if (arg === undefined) continue;
45
25
- if (arg === "--strict-config" || arg.startsWith("--config=") || arg.startsWith("-c=")) {
26
- execArgs.push(arg);
27
- } else if (arg === "--config" || arg === "-c" || arg === "--enable" || arg === "--disable") {
46
+ if (allowed.switches.has(arg)) {
47
+ kept.push(arg);
48
+ } else if (allowed.valueFlags.has(arg)) {
49
const value = args[index + 1];
50
if (value !== undefined && !value.startsWith("-")) {
30
- execArgs.push(arg, value);
51
+ kept.push(arg, value);
52
index++;
53
}
33
- } else if (arg.startsWith("--enable=") || arg.startsWith("--disable=")) {
34
- execArgs.push(arg);
54
+ } else if (allowed.inlinePrefixes.some((prefix) => arg.startsWith(prefix))) {
55
+ kept.push(arg);
56
}
57
}
58
38
- return execArgs;
59
+ return kept;
60
};
61
+
62
+export const codexExecLaunchArgs = (launchArgs?: string) =>
63
+ filterLaunchArgs(launchArgs, EXEC_FILTER);
64
+
65
+export const codexMcpListLaunchArgs = (launchArgs?: string) =>
66
+ filterLaunchArgs(launchArgs, MCP_LIST_FILTER);
apps/server/src/textGeneration/CodexTextGeneration.test.ts
+2
-2
@@ -431,8 +431,8 @@ it.layer(layerCodexTextGenerationTest)("CodexTextGeneration", (it) => {
431
subject: "Add important change",
432
body: "",
433
}),
434
- launchArgs: "--strict-config --listen off",
435
- requireArg: "--strict-config",
434
+ launchArgs: "--strict-config --oss --local-provider ollama --listen off",
435
+ requireArg: "--strict-config --oss --local-provider ollama",
436
forbidArg: "--listen",
437
},
438
(textGeneration) =>
apps/server/src/textGeneration/CodexTextGeneration.ts
+7
-5
@@ -18,7 +18,11 @@ import { resolveSpawnCommand } from "@t3tools/shared/shell";
18
import { resolveAttachmentPath } from "../attachmentStore.ts";
19
import * as ServerConfig from "../config.ts";
20
import { expandHomePath } from "@t3tools/provider-core/server/pathExpansion";
21
-import { codexExecLaunchArgs, resolveCodexLaunchArgs } from "../provider/codexLaunchArgs.ts";
21
+import {
22
+ codexExecLaunchArgs,
23
+ codexMcpListLaunchArgs,
24
+ resolveCodexLaunchArgs,
25
+} from "../provider/codexLaunchArgs.ts";
26
import * as TextGenerationOperations from "@t3tools/provider-core/server/textGenerationOperations";
27
import {
28
normalizeCliError,
@@ -287,19 +291,17 @@ export const makeCodexTextGeneration = Effect.fn("makeCodexTextGeneration")(func
291
}
292
: {}),
293
};
290
- const execLaunchArgs = codexExecLaunchArgs(launchArgs);
294
const mcpServersOff = yield* listEnabledMcpServers({
295
binary,
296
cwd,
297
env,
295
- // `codex mcp` rejects --strict-config; the overrides still apply.
296
- launchArgs: execLaunchArgs.filter((arg) => arg !== "--strict-config"),
298
+ launchArgs: codexMcpListLaunchArgs(launchArgs),
299
}).pipe(Effect.map(codexMcpServersOff));
300
const spawnCommand = yield* resolveSpawnCommand(
301
binary,
302
[
303
"exec",
302
- ...execLaunchArgs,
304
+ ...codexExecLaunchArgs(launchArgs),
305
// A user's MCP server could act on the text-generation prompt.
306
...CODEX_NO_PLUGIN_ARGS,
307
...(mcpServersOff ? ["--config", mcpServersOff] : []),