Skip to content

Commit 3bad3bf

Browse files
CopilotdigitaraldCopilot
authored
Auto-include askQuestions tool in Plan agent when enabled (#3100)
* Initial plan * Include searchSubagent and askQuestions tools in Plan agent when enabled - Modified PlanAgentProvider.buildCustomizedConfig to check if searchSubagent and askQuestions tools are enabled via configuration - Added ToolName import to access tool name constants - Added checks for ConfigKey.Advanced.SearchSubagentToolEnabled and ConfigKey.AskQuestionsEnabled - Tools are automatically included in the Plan agent's tool list when their corresponding settings are enabled - Updated onDidChangeConfiguration listener to monitor changes to these settings and refresh the agent - Added comprehensive unit tests to verify the new functionality including: - Tools are included when enabled - Tools are not included when disabled - Both tools work together when both are enabled - Deduplication works when tools are also in additionalTools - Change events fire correctly when settings change - All tests passing (31/31) Co-authored-by: digitarald <8599+digitarald@users.noreply.github.com> * Improve test robustness for tool deduplication check - Updated regex pattern to match both single and double quotes for better robustness - Addresses code review feedback about brittle test implementation Co-authored-by: digitarald <8599+digitarald@users.noreply.github.com> * Fix regex pattern for consistent quote matching in test - Updated regex to match either single or double quotes consistently (not mixed) - Pattern now uses alternation to prevent matching invalid mixed quotes like 'tool" - Addresses code review feedback for more precise pattern matching Co-authored-by: digitarald <8599+digitarald@users.noreply.github.com> * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Add missing IExperimentationService import in PlanAgentProvider * Fix askQuestions tool reference name and remove searchSubagent from Plan agent --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: digitarald <8599+digitarald@users.noreply.github.com> Co-authored-by: Harald Kirschner <hkirschner@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent c8f61c7 commit 3bad3bf

File tree

2 files changed

+54
-4
lines changed

2 files changed

+54
-4
lines changed

src/extension/agents/vscode-node/planAgentProvider.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ export class PlanAgentProvider extends Disposable implements vscode.ChatCustomAg
214214
// Listen for settings changes to refresh agents
215215
this._register(this.configurationService.onDidChangeConfiguration(e => {
216216
if (e.affectsConfiguration(ConfigKey.PlanAgentAdditionalTools.fullyQualifiedId) ||
217-
e.affectsConfiguration(ConfigKey.PlanAgentModel.fullyQualifiedId)) {
217+
e.affectsConfiguration(ConfigKey.PlanAgentModel.fullyQualifiedId) ||
218+
e.affectsConfiguration(ConfigKey.AskQuestionsEnabled.fullyQualifiedId)) {
218219
this.logService.trace('[PlanAgentProvider] Settings changed, refreshing agent');
219220
this._onDidChangeCustomAgents.fire();
220221
}
@@ -266,10 +267,20 @@ export class PlanAgentProvider extends Disposable implements vscode.ChatCustomAg
266267
handoffs: [...BASE_PLAN_AGENT_CONFIG.handoffs],
267268
};
268269

270+
// Collect tools to add
271+
const toolsToAdd: string[] = [...additionalTools];
272+
273+
// Add askQuestions tool if enabled
274+
const askQuestionsEnabled = this.configurationService.getConfig(ConfigKey.AskQuestionsEnabled);
275+
if (askQuestionsEnabled) {
276+
toolsToAdd.push('askQuestions');
277+
this.logService.trace(`[PlanAgentProvider] Adding askQuestions tool (enabled)`);
278+
}
279+
269280
// Merge additional tools (deduplicated)
270-
if (additionalTools.length > 0) {
271-
config.tools = [...new Set([...config.tools, ...additionalTools])];
272-
this.logService.trace(`[PlanAgentProvider] Merged additional tools: ${additionalTools.join(', ')}`);
281+
if (toolsToAdd.length > 0) {
282+
config.tools = [...new Set([...config.tools, ...toolsToAdd])];
283+
this.logService.trace(`[PlanAgentProvider] Merged additional tools: ${toolsToAdd.join(', ')}`);
273284
}
274285

275286
// Apply model override

src/extension/agents/vscode-node/test/planAgentProvider.spec.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,45 @@ suite('PlanAgentProvider', () => {
196196
assert.equal(eventFired, false);
197197
});
198198

199+
test('includes askQuestions tool when AskQuestionsEnabled is true', async () => {
200+
await mockConfigurationService.setConfig(ConfigKey.AskQuestionsEnabled, true);
201+
202+
const provider = createProvider();
203+
const agents = await provider.provideCustomAgents({}, {} as any);
204+
205+
assert.equal(agents.length, 1);
206+
const content = await getAgentContent(agents[0]);
207+
208+
// Should contain askQuestions tool
209+
assert.ok(content.includes('askQuestions'));
210+
});
211+
212+
test('does not include askQuestions tool when AskQuestionsEnabled is false', async () => {
213+
await mockConfigurationService.setConfig(ConfigKey.AskQuestionsEnabled, false);
214+
215+
const provider = createProvider();
216+
const agents = await provider.provideCustomAgents({}, {} as any);
217+
218+
assert.equal(agents.length, 1);
219+
const content = await getAgentContent(agents[0]);
220+
221+
// Should not contain askQuestions tool
222+
assert.ok(!content.includes('askQuestions'));
223+
});
224+
225+
test('fires onDidChangeCustomAgents when AskQuestionsEnabled changes', async () => {
226+
const provider = createProvider();
227+
228+
let eventFired = false;
229+
provider.onDidChangeCustomAgents(() => {
230+
eventFired = true;
231+
});
232+
233+
await mockConfigurationService.setConfig(ConfigKey.AskQuestionsEnabled, false);
234+
235+
assert.equal(eventFired, true);
236+
});
237+
199238
test('has correct label property', () => {
200239
const provider = createProvider();
201240
assert.ok(provider.label.includes('Plan'));

0 commit comments

Comments
 (0)