diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index bc52050286..1f2c578f29 100644 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -779,7 +779,7 @@ export class Config implements McpContext, AgentLoopContext { | undefined; private disabledHooks: string[]; private experiments: Experiments | undefined; - private experimentsPromise: Promise | undefined; + private experimentsPromise: Promise | undefined; private hookSystem?: HookSystem; private readonly onModelChange: ((model: string) => void) | undefined; private readonly onReload: @@ -1269,18 +1269,22 @@ export class Config implements McpContext, AgentLoopContext { this.baseLlmClient = new BaseLlmClient(this.contentGenerator, this); const codeAssistServer = getCodeAssistServer(this); - if (codeAssistServer?.projectId) { - await this.refreshUserQuota(); - } + const quotaPromise = codeAssistServer?.projectId + ? this.refreshUserQuota() + : Promise.resolve(); this.experimentsPromise = getExperiments(codeAssistServer) .then((experiments) => { this.setExperiments(experiments); + return experiments; }) .catch((e) => { debugLogger.error('Failed to fetch experiments', e); + return undefined; }); + await quotaPromise; + const authType = this.contentGeneratorConfig.authType; if ( authType === AuthType.USE_GEMINI || @@ -1296,10 +1300,10 @@ export class Config implements McpContext, AgentLoopContext { } // Fetch admin controls - await this.ensureExperimentsLoaded(); + const experiments = await this.experimentsPromise; const adminControlsEnabled = - this.experiments?.flags[ExperimentFlags.ENABLE_ADMIN_CONTROLS] - ?.boolValue ?? false; + experiments?.flags[ExperimentFlags.ENABLE_ADMIN_CONTROLS]?.boolValue ?? + false; const adminControls = await fetchAdminControls( codeAssistServer, this.getRemoteAdminSettings(),