Skip to content

Commit 47819da

Browse files
fix(server): preserve managed Codex provider identity across sign-ins
1 parent 281f81e commit 47819da

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎apps/server/src/provider/CodexManagedRuntime.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,9 @@ it.live.each(
138138
assert.isUndefined(effective.environment.OPENAI_BASE_URL);
139139
assert.isUndefined(effective.environment.T3CODE_CODEX_LAUNCH_ARGS);
140140
const args = codexAppServerArgs(effective.config.launchArgs);
141+
assert.include(args, 'model_provider="openai_token_sharing"');
141142
const provider = args.find((arg) =>
142-
arg.startsWith("model_providers.openai_token_sharing_"),
143+
arg.startsWith("model_providers.openai_token_sharing="),
143144
)!;
144145
assert.include(provider, 'base_url="https://api.openai.com/v1"');
145146
assert.include(provider, 'model_catalog_url="https://api.openai.com/v1/models"');

‎apps/server/src/provider/CodexManagedRuntime.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ export interface CodexEffectiveRuntime {
1919
readonly revision: string;
2020
}
2121
const decodeSettings = Schema.decodeSync(CodexSettings);
22-
const managedCodexLaunchArgs = (profileKey: string, command: string, args: ReadonlyArray<string>) =>
22+
const managedCodexLaunchArgs = (command: string, args: ReadonlyArray<string>) =>
2323
[
24-
`model_provider="openai_token_sharing_${profileKey}"`,
25-
// Codex recursively merges -c tables. A profile-specific key avoids inheriting
26-
// auth fields or headers from a shared openai_token_sharing provider.
27-
`model_providers.openai_token_sharing_${profileKey}={name="OpenAI Token Sharing",base_url="https://api.openai.com/v1",model_catalog_url="https://api.openai.com/v1/models",wire_api="responses",requires_openai_auth=false,supports_websockets=false,auth={command=${JSON.stringify(command)},args=${JSON.stringify(args)},timeout_ms=${COMMAND_TIMEOUT_MS},refresh_interval_ms=0}}`,
24+
'model_provider="openai_token_sharing"',
25+
// Codex persists this provider ID in rollouts and needs it unchanged to resume.
26+
`model_providers.openai_token_sharing={name="OpenAI Token Sharing",base_url="https://api.openai.com/v1",model_catalog_url="https://api.openai.com/v1/models",wire_api="responses",requires_openai_auth=false,supports_websockets=false,auth={command=${JSON.stringify(command)},args=${JSON.stringify(args)},timeout_ms=${COMMAND_TIMEOUT_MS},refresh_interval_ms=0}}`,
2827
"features.api_key_model_discovery=true",
2928
"features.multi_agent=false",
3029
"features.multi_agent_v2=false",
@@ -129,7 +128,7 @@ export const makeCodexManagedRuntime = Effect.fn("makeCodexManagedRuntime")(func
129128
setupMode: "managed",
130129
binaryPath: executable.executablePath,
131130
homePath,
132-
launchArgs: managedCodexLaunchArgs(profileKey, invocation.command, authArgs),
131+
launchArgs: managedCodexLaunchArgs(invocation.command, authArgs),
133132
}),
134133
environment,
135134
revision: profileKey,

0 commit comments

Comments
 (0)