From 90d6ed901205ae1c576933943549b711b3149e73 Mon Sep 17 00:00:00 2001 From: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com> Date: Thu, 24 Sep 2026 11:23:33 -0700 Subject: [PATCH] fix(server): Codex V2 sessions use the configured launch arguments The V2 Codex client factory spawned `codex app-server` with hard-coded arguments, so the provider's "Launch arguments" setting and the T3CODE_CODEX_LAUNCH_ARGS override never reached real sessions. Resolve them the same way the readiness probe and text generation do. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../Adapters/CodexAdapterV2.test.ts | 50 +++++++++++++++++++ .../Adapters/CodexAdapterV2.ts | 8 ++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts index 9392ae4047d6..043fccbc9a02 100644 --- a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts @@ -38,6 +38,7 @@ import * as Predicate from "effect/Predicate"; import * as FileSystem from "effect/FileSystem"; import * as Fiber from "effect/Fiber"; import * as Layer from "effect/Layer"; +import * as PlatformError from "effect/PlatformError"; import * as Ref from "effect/Ref"; import * as Schema from "effect/Schema"; import * as Stream from "effect/Stream"; @@ -46,6 +47,10 @@ import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"; import * as McpProviderSession from "../../mcp/McpProviderSession.ts"; import type { EventNdjsonLogger } from "../../provider/Layers/EventNdjsonLogger.ts"; +import { + NoOpProviderEventLoggers, + ProviderEventLoggers, +} from "../../provider/Layers/ProviderEventLoggers.ts"; import { layer as idAllocatorLayer, IdAllocatorV2 } from "../IdAllocator.ts"; import { OrchestrationEffectWorkerV2 } from "../EffectWorker.ts"; import { OrchestratorV2 } from "../Orchestrator.ts"; @@ -68,6 +73,8 @@ import { codexFileChangeApprovalPrompt, codexProviderTurnTokenUsage, codexThreadRuntimeParams, + CodexAppServerClientFactory, + codexAppServerClientFactoryFromSettingsLayer, type CodexAppServerClientFactoryShape, makeCodexAdapterV2, makeCodexAppServerProtocolLogger, @@ -695,6 +702,49 @@ describe("CodexAdapterV2 process spawning", () => { Effect.provideService(SpawnExecutableResolution, () => "C:\\bin\\codex.exe"), ), ); + + it.effect("launches the app-server with the configured launch arguments", () => + Effect.gen(function* () { + const spawnedArgs: Array> = []; + const spawner = ChildProcessSpawner.make((command) => { + if (ChildProcess.isStandardCommand(command)) spawnedArgs.push(command.args); + return Effect.fail( + PlatformError.systemError({ _tag: "NotFound", module: "ChildProcess", method: "spawn" }), + ); + }); + const factory = yield* CodexAppServerClientFactory.pipe( + Effect.provide(codexAppServerClientFactoryFromSettingsLayer), + Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner), + Effect.provideService(ProviderEventLoggers, NoOpProviderEventLoggers), + ); + const open = (environment: NodeJS.ProcessEnv) => + factory + .open({ + instanceId: CODEX_DEFAULT_INSTANCE_ID, + threadId: ThreadId.make("thread-launch-args"), + providerSessionId: ProviderSessionId.make("provider-session-launch-args"), + runtimePolicy: ProviderAdapterV2RuntimePolicy.make({ + runtimeMode: "full-access", + interactionMode: "default", + cwd: "/workspace", + }), + settings: { + ...DEFAULT_CODEX_SETTINGS, + launchArgs: " --strict-config -c model_reasoning_summary=detailed ", + }, + environment, + }) + .pipe(Effect.scoped, Effect.exit); + + yield* open({}); + yield* open({ T3CODE_CODEX_LAUNCH_ARGS: " --enable env-feature " }); + + assert.deepEqual(spawnedArgs, [ + ["app-server", "--strict-config", "-c", "model_reasoning_summary=detailed"], + ["app-server", "--enable", "env-feature"], + ]); + }).pipe(Effect.provideService(HostProcessPlatform, "linux")), + ); }); describe("CodexAdapterV2 dynamic tool projection", () => { diff --git a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts index bdce415abe81..2d2570f6b8ad 100644 --- a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts +++ b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts @@ -93,6 +93,10 @@ import { shouldPersistProviderEvent, } from "../../provider/Layers/EventNdjsonLogger.ts"; import { ProviderEventLoggers } from "../../provider/Layers/ProviderEventLoggers.ts"; +import { + codexAppServerArgs, + resolveCodexLaunchArgs, +} from "../../provider/Layers/codexLaunchArgs.ts"; import { mergeProviderInstanceEnvironment } from "../../provider/ProviderInstanceEnvironment.ts"; import * as McpProviderSession from "../../mcp/McpProviderSession.ts"; import { @@ -1325,7 +1329,9 @@ export const codexAppServerClientFactoryFromSettingsLayer: Layer.Layer< }; const command = yield* makeCodexAppServerSpawnCommand({ command: input.settings.binaryPath || "codex", - args: ["app-server"], + args: codexAppServerArgs( + resolveCodexLaunchArgs(input.settings.launchArgs, input.environment), + ), env: environment, }); const handle = yield* spawner.spawn(command).pipe(