Roo-Code/src/shared/experiments.ts
Roo Code a64af0ec6d feat: add multi-tool calls experiment
- Add multiToolCalls to ExperimentId type
- Update experiments schema and configuration
- Add MULTI_TOOL_CALLS constant to shared experiments
- Update tool-use prompt to conditionally support multi-tool calls
- Add i18n translations for EN and zh-CN
- Update test fixtures to include multiToolCalls property

Implements #9288
2025-11-16 01:54:16 +00:00

39 lines
1.4 KiB
TypeScript

import type { AssertEqual, Equals, Keys, Values, ExperimentId, Experiments } from "@roo-code/types"
export const EXPERIMENT_IDS = {
MULTI_FILE_APPLY_DIFF: "multiFileApplyDiff",
POWER_STEERING: "powerSteering",
PREVENT_FOCUS_DISRUPTION: "preventFocusDisruption",
IMAGE_GENERATION: "imageGeneration",
RUN_SLASH_COMMAND: "runSlashCommand",
MULTI_TOOL_CALLS: "multiToolCalls",
} as const satisfies Record<string, ExperimentId>
type _AssertExperimentIds = AssertEqual<Equals<ExperimentId, Values<typeof EXPERIMENT_IDS>>>
type ExperimentKey = Keys<typeof EXPERIMENT_IDS>
interface ExperimentConfig {
enabled: boolean
}
export const experimentConfigsMap: Record<ExperimentKey, ExperimentConfig> = {
MULTI_FILE_APPLY_DIFF: { enabled: false },
POWER_STEERING: { enabled: false },
PREVENT_FOCUS_DISRUPTION: { enabled: false },
IMAGE_GENERATION: { enabled: false },
RUN_SLASH_COMMAND: { enabled: false },
MULTI_TOOL_CALLS: { enabled: false },
}
export const experimentDefault = Object.fromEntries(
Object.entries(experimentConfigsMap).map(([_, config]) => [
EXPERIMENT_IDS[_ as keyof typeof EXPERIMENT_IDS] as ExperimentId,
config.enabled,
]),
) as Record<ExperimentId, boolean>
export const experiments = {
get: (id: ExperimentKey): ExperimentConfig | undefined => experimentConfigsMap[id],
isEnabled: (experimentsConfig: Experiments, id: ExperimentId) => experimentsConfig[id] ?? experimentDefault[id],
} as const