Change flag name to flag id for existing flags (#13073)

This commit is contained in:
Adib234
2025-11-14 13:34:54 -08:00
committed by GitHub
parent ba15eeb55f
commit ce56b4ee1b
5 changed files with 15 additions and 16 deletions

View File

@@ -42,8 +42,8 @@ describe('experiments', () => {
const { getExperiments } = await import('./experiments.js');
const mockApiResponse: ListExperimentsResponse = {
flags: [
{ name: 'flag1', boolValue: true },
{ name: 'flag2', stringValue: 'value' },
{ flagId: 234, boolValue: true },
{ flagId: 345, stringValue: 'value' },
],
experimentIds: [123, 456],
};
@@ -58,12 +58,12 @@ describe('experiments', () => {
);
// Verify that the response was parsed correctly
expect(experiments.flags['flag1']).toEqual({
name: 'flag1',
expect(experiments.flags[234]).toEqual({
flagId: 234,
boolValue: true,
});
expect(experiments.flags['flag2']).toEqual({
name: 'flag2',
expect(experiments.flags[345]).toEqual({
flagId: 345,
stringValue: 'value',
});
expect(experiments.experimentIds).toEqual([123, 456]);
@@ -85,7 +85,7 @@ describe('experiments', () => {
const mockApiResponse: ListExperimentsResponse = {
flags: [
{ boolValue: true } as Flag, // No name
{ name: 'flag2', stringValue: 'value' },
{ flagId: 256, stringValue: 'value' },
],
};
vi.mocked(mockServer.listExperiments).mockResolvedValue(mockApiResponse);
@@ -93,7 +93,7 @@ describe('experiments', () => {
const experiments = await getExperiments(mockServer);
expect(Object.keys(experiments.flags)).toHaveLength(1);
expect(experiments.flags['flag2']).toBeDefined();
expect(experiments.flags[256]).toBeDefined();
expect(experiments.flags['undefined']).toBeUndefined();
});

View File

@@ -38,8 +38,8 @@ export async function getExperiments(
function parseExperiments(response: ListExperimentsResponse): Experiments {
const flags: Record<string, Flag> = {};
for (const flag of response.flags ?? []) {
if (flag.name) {
flags[flag.name] = flag;
if (flag.flagId) {
flags[flag.flagId] = flag;
}
}
return {

View File

@@ -5,9 +5,8 @@
*/
export const ExperimentFlags = {
CONTEXT_COMPRESSION_THRESHOLD:
'GeminiCLIContextCompression__threshold_fraction',
USER_CACHING: 'GcliUserCaching__user_caching',
CONTEXT_COMPRESSION_THRESHOLD: 45740197,
USER_CACHING: 45740198,
} as const;
export type ExperimentFlagName =

View File

@@ -19,7 +19,7 @@ export interface ListExperimentsResponse {
}
export interface Flag {
name?: string;
flagId?: number;
boolValue?: boolean;
floatValue?: number;
intValue?: string; // int64

View File

@@ -1425,8 +1425,8 @@ export class Config {
this.experiments = experiments;
const flagSummaries = Object.entries(experiments.flags ?? {})
.sort(([a], [b]) => a.localeCompare(b))
.map(([name, flag]) => {
const summary: Record<string, unknown> = { name };
.map(([flagId, flag]) => {
const summary: Record<string, unknown> = { flagId };
if (flag.boolValue !== undefined) {
summary['boolValue'] = flag.boolValue;
}