From 0e5c5b6f49beb49a884a5e175dd35d25a56dc666 Mon Sep 17 00:00:00 2001 From: Sehoon Shon Date: Mon, 20 Apr 2026 13:29:58 -0400 Subject: [PATCH] fix(core): allow Cloud Shell users to use PRO_MODEL_NO_ACCESS experiment (#25702) --- packages/core/src/config/config.test.ts | 53 +++++++++++++++++++++++++ packages/core/src/config/config.ts | 5 ++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/packages/core/src/config/config.test.ts b/packages/core/src/config/config.test.ts index ec609f294e..97531a5190 100644 --- a/packages/core/src/config/config.test.ts +++ b/packages/core/src/config/config.test.ts @@ -710,6 +710,59 @@ describe('Server Config (config.ts)', () => { ); }); + describe('getProModelNoAccessSync', () => { + it('should return experiment value for AuthType.LOGIN_WITH_GOOGLE', async () => { + vi.mocked(getExperiments).mockResolvedValue({ + experimentIds: [], + flags: { + [ExperimentFlags.PRO_MODEL_NO_ACCESS]: { + boolValue: true, + }, + }, + }); + const config = new Config(baseParams); + vi.mocked(createContentGeneratorConfig).mockResolvedValue({ + authType: AuthType.LOGIN_WITH_GOOGLE, + }); + await config.refreshAuth(AuthType.LOGIN_WITH_GOOGLE); + expect(config.getProModelNoAccessSync()).toBe(true); + }); + + it('should return experiment value for AuthType.COMPUTE_ADC', async () => { + vi.mocked(getExperiments).mockResolvedValue({ + experimentIds: [], + flags: { + [ExperimentFlags.PRO_MODEL_NO_ACCESS]: { + boolValue: true, + }, + }, + }); + const config = new Config(baseParams); + vi.mocked(createContentGeneratorConfig).mockResolvedValue({ + authType: AuthType.COMPUTE_ADC, + }); + await config.refreshAuth(AuthType.COMPUTE_ADC); + expect(config.getProModelNoAccessSync()).toBe(true); + }); + + it('should return false for other auth types even if experiment is true', async () => { + vi.mocked(getExperiments).mockResolvedValue({ + experimentIds: [], + flags: { + [ExperimentFlags.PRO_MODEL_NO_ACCESS]: { + boolValue: true, + }, + }, + }); + const config = new Config(baseParams); + vi.mocked(createContentGeneratorConfig).mockResolvedValue({ + authType: AuthType.USE_GEMINI, + }); + await config.refreshAuth(AuthType.USE_GEMINI); + expect(config.getProModelNoAccessSync()).toBe(false); + }); + }); + describe('getRequestTimeoutMs', () => { it('should return undefined if the flag is not set', () => { const config = new Config(baseParams); diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index 01c6fd7bfd..76c571e29e 100644 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -3160,7 +3160,10 @@ export class Config implements McpContext, AgentLoopContext { * Note: This method should only be called after startup, once experiments have been loaded. */ getProModelNoAccessSync(): boolean { - if (this.contentGeneratorConfig?.authType !== AuthType.LOGIN_WITH_GOOGLE) { + if ( + this.contentGeneratorConfig?.authType !== AuthType.LOGIN_WITH_GOOGLE && + this.contentGeneratorConfig?.authType !== AuthType.COMPUTE_ADC + ) { return false; } return (