Skip to content

Commit d2711c9

Browse files
committed
perf(gateway): reuse prepared auth stores
1 parent 1ce3637 commit d2711c9

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

extensions/codex/src/app-server/auth-bridge.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ function resolveCodexAppServerAuthProfileStore(params: {
131131
authProfileStore?: AuthProfileStore;
132132
config?: AuthProfileOrderConfig;
133133
}): AuthProfileStore {
134+
if (params.authProfileStore) {
135+
const providedProfileId = resolveCodexAppServerAuthProfileId({
136+
authProfileId: params.authProfileId,
137+
store: params.authProfileStore,
138+
config: params.config,
139+
});
140+
if (providedProfileId && params.authProfileStore.profiles[providedProfileId]) {
141+
return params.authProfileStore;
142+
}
143+
}
134144
const overlaidStore = ensureCodexAppServerAuthProfileStore({
135145
agentDir: params.agentDir,
136146
authProfileId: params.authProfileId,

extensions/codex/src/app-server/run-attempt.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4315,9 +4315,14 @@ async function buildDynamicTools(input: DynamicToolBuildParams) {
43154315
: undefined,
43164316
modelApi: params.model.api,
43174317
modelContextWindowTokens: params.model.contextWindow,
4318-
modelAuthMode: resolveModelAuthMode(params.model.provider, params.config, undefined, {
4319-
workspaceDir: input.effectiveWorkspace,
4320-
}),
4318+
modelAuthMode: resolveModelAuthMode(
4319+
params.model.provider,
4320+
params.config,
4321+
params.toolAuthProfileStore ?? params.authProfileStore,
4322+
{
4323+
workspaceDir: input.effectiveWorkspace,
4324+
},
4325+
),
43214326
suppressManagedWebSearch: false,
43224327
currentChannelId: params.currentChannelId,
43234328
hookChannelId: resolveCodexAppServerHookChannelId(params, input.sandboxSessionKey),

src/agents/command/attempt-execution.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ function resolveProfileAuthFromStore(params: { agentDir: string; profileId: stri
136136
}
137137
const credential = ensureAuthProfileStore(params.agentDir, {
138138
allowKeychainPrompt: false,
139+
externalCliProfileIds: [profileId],
139140
}).profiles[profileId];
140141
return { provider: credential?.provider, mode: credential?.type };
141142
}
@@ -182,6 +183,7 @@ function resolveHarnessAuthProfileSelection(params: {
182183

183184
const store = ensureAuthProfileStore(params.agentDir, {
184185
allowKeychainPrompt: false,
186+
externalCliProviderIds: [harnessAuthProvider],
185187
});
186188
const authProfileId = resolveAuthProfileOrder({
187189
cfg: params.config,

0 commit comments

Comments
 (0)