Skip to content

Commit f88b90e

Browse files
authored
tools: add a config option to enable gemini replace string (#283)
Useful for testing. Also, add a way to explicitly specify config experiments so we don't have to restart ours.
1 parent 3804d13 commit f88b90e

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/extension/intents/node/agentIntent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const getTools = (instaService: IInstantiationService, request: vscode.ChatReque
5959

6060
const allowTools: Record<string, boolean> = {};
6161
allowTools[ToolName.EditFile] = true;
62-
allowTools[ToolName.ReplaceString] = modelSupportsReplaceString(model) || !!(model.family.includes('gemini') && experimentationService.getTreatmentVariable<boolean>('vscode', 'copilotchat.geminiReplaceString'));
62+
allowTools[ToolName.ReplaceString] = modelSupportsReplaceString(model) || !!(model.family.includes('gemini') && configurationService.getExperimentBasedConfig(ConfigKey.Internal.GeminiReplaceString, experimentationService));
6363
allowTools[ToolName.ApplyPatch] = modelSupportsApplyPatch(model) && !!toolsService.getTool(ToolName.ApplyPatch);
6464

6565
if (modelCanUseReplaceStringExclusively(model)) {

src/platform/configuration/common/configurationService.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ export interface Config<T> extends BaseConfig<T> {
399399

400400
export interface ExperimentBasedConfig<T extends ExperimentBasedConfigType> extends BaseConfig<T> {
401401
readonly configType: ConfigType.ExperimentBased;
402+
readonly experimentName: string | undefined;
402403
}
403404

404405
let packageJsonDefaults: Map<string, any> | undefined = undefined;
@@ -488,8 +489,8 @@ function defineSetting<T>(key: string, defaultValue: T | DefaultValueWithTeamVal
488489
* config.github.copilot.chat.advanced.inlineEdits.internalRollout
489490
* ```
490491
*/
491-
export function defineExpSetting<T extends ExperimentBasedConfigType>(key: string, defaultValue: T | DefaultValueWithTeamValue<T> | DefaultValueWithTeamAndInternalValue<T>, options?: ConfigOptions): ExperimentBasedConfig<T> {
492-
const value: ExperimentBasedConfig<T> = { ...toBaseConfig(key, defaultValue, options), configType: ConfigType.ExperimentBased };
492+
export function defineExpSetting<T extends ExperimentBasedConfigType>(key: string, defaultValue: T | DefaultValueWithTeamValue<T> | DefaultValueWithTeamAndInternalValue<T>, options?: ConfigOptions, expOptions?: { experimentName?: string }): ExperimentBasedConfig<T> {
493+
const value: ExperimentBasedConfig<T> = { ...toBaseConfig(key, defaultValue, options), configType: ConfigType.ExperimentBased, experimentName: expOptions?.experimentName };
493494
if (value.advancedSubKey) {
494495
// This is a `github.copilot.advanced.*` setting
495496
throw new BugIndicatingError('Shared settings cannot be experiment based');
@@ -714,6 +715,7 @@ export namespace ConfigKey {
714715
export const VerifyTextDocumentChanges = defineExpSetting<boolean>('chat.advanced.inlineEdits.verifyTextDocumentChanges', true, INTERNAL_RESTRICTED);
715716
export const EnableApplyPatchForNotebooks = defineExpSetting<boolean>('chat.advanced.enableApplyPatchForNotebooks', false, INTERNAL_RESTRICTED);
716717
export const OmitBaseAgentInstructions = defineSetting<boolean>('chat.advanced.omitBaseAgentInstructions', false, INTERNAL);
718+
export const GeminiReplaceString = defineExpSetting<boolean>('chat.advanced.geminiReplaceString.enabled', false, INTERNAL, { experimentName: 'copilotchat.geminiReplaceString' });
717719
}
718720

719721
export const AgentThinkingTool = defineSetting<boolean>('chat.agent.thinkingTool', false);

src/platform/configuration/vscode/configurationServiceImpl.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ export class ConfigurationServiceImpl extends AbstractConfigurationService {
170170
return configuredValue;
171171
}
172172

173+
if (key.experimentName) {
174+
const expValue = experimentationService.getTreatmentVariable<Exclude<T, undefined>>('vscode', key.experimentName);
175+
if (expValue !== undefined) {
176+
return expValue;
177+
}
178+
}
179+
173180
// This is the pattern we've been using for a while now. We need to maintain it for older experiments.
174181
const expValue = experimentationService.getTreatmentVariable<Exclude<T, undefined>>('vscode', `copilotchat.config.${key.id}`);
175182
if (expValue !== undefined) {

0 commit comments

Comments
 (0)