inject plan agent instructions into tool response (#3256)

This commit is contained in:
SteVen Batten
2026-01-28 20:10:17 -08:00
committed by GitHub
parent 12540480f0
commit 8aebaedabe
2 changed files with 28 additions and 15 deletions
@@ -206,19 +206,8 @@ export class PlanAgentProvider extends Disposable implements vscode.ChatCustomAg
return fileUri;
}
private buildCustomizedConfig(): PlanAgentConfig {
const additionalTools = this.configurationService.getConfig(ConfigKey.PlanAgentAdditionalTools);
const modelOverride = this.configurationService.getConfig(ConfigKey.PlanAgentModel);
// Check askQuestions config first (needed for both tools and body)
const askQuestionsEnabled = this.configurationService.getConfig(ConfigKey.AskQuestionsEnabled);
// Start with base config, using dynamic body based on askQuestions setting
const config: PlanAgentConfig = {
...BASE_PLAN_AGENT_CONFIG,
tools: [...BASE_PLAN_AGENT_CONFIG.tools],
handoffs: [...BASE_PLAN_AGENT_CONFIG.handoffs],
body: `You are a PLANNING AGENT, pairing with the user to create a detailed, actionable plan.
static buildAgentBody(askQuestionsEnabled: boolean): string {
return `You are a PLANNING AGENT, pairing with the user to create a detailed, actionable plan.
Your job: research the codebase → clarify with the user → produce a comprehensive plan. This iterative approach catches edge cases and non-obvious requirements BEFORE implementation begins.
@@ -304,7 +293,22 @@ Rules:
- NO code blocks — describe changes, link to files/symbols
- NO questions at the end${askQuestionsEnabled ? ' — ask during workflow via #tool:vscode/askQuestions' : ''}
- Keep scannable
</plan_style_guide>`,
</plan_style_guide>`;
}
private buildCustomizedConfig(): PlanAgentConfig {
const additionalTools = this.configurationService.getConfig(ConfigKey.PlanAgentAdditionalTools);
const modelOverride = this.configurationService.getConfig(ConfigKey.PlanAgentModel);
// Check askQuestions config first (needed for both tools and body)
const askQuestionsEnabled = this.configurationService.getConfig(ConfigKey.AskQuestionsEnabled);
// Start with base config, using dynamic body based on askQuestions setting
const config: PlanAgentConfig = {
...BASE_PLAN_AGENT_CONFIG,
tools: [...BASE_PLAN_AGENT_CONFIG.tools],
handoffs: [...BASE_PLAN_AGENT_CONFIG.handoffs],
body: PlanAgentProvider.buildAgentBody(askQuestionsEnabled)
};
// Collect tools to add
@@ -4,8 +4,10 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { ConfigKey, IConfigurationService } from '../../../platform/configuration/common/configurationService';
import { CancellationToken } from '../../../util/vs/base/common/cancellation';
import { LanguageModelTextPart, LanguageModelToolResult, MarkdownString } from '../../../vscodeTypes';
import { PlanAgentProvider } from '../../agents/vscode-node/planAgentProvider';
import { ToolName } from '../common/toolNames';
import { ICopilotTool, ToolRegistry } from '../common/toolsRegistry';
@@ -16,6 +18,10 @@ interface ISwitchAgentParams {
export class SwitchAgentTool implements ICopilotTool<ISwitchAgentParams> {
public static readonly toolName = ToolName.SwitchAgent;
constructor(
@IConfigurationService private readonly configurationService: IConfigurationService,
) { }
async invoke(options: vscode.LanguageModelToolInvocationOptions<ISwitchAgentParams>, token: CancellationToken): Promise<vscode.LanguageModelToolResult> {
const { agentName } = options.input;
@@ -24,6 +30,9 @@ export class SwitchAgentTool implements ICopilotTool<ISwitchAgentParams> {
throw new Error(vscode.l10n.t('Only "Plan" agent is supported'));
}
const askQuestionsEnabled = this.configurationService.getConfig(ConfigKey.AskQuestionsEnabled);
const planAgentBody = PlanAgentProvider.buildAgentBody(askQuestionsEnabled);
// Execute command to switch agent
await vscode.commands.executeCommand('workbench.action.chat.toggleAgentMode', {
modeId: agentName,
@@ -31,7 +40,7 @@ export class SwitchAgentTool implements ICopilotTool<ISwitchAgentParams> {
});
return new LanguageModelToolResult([
new LanguageModelTextPart(`Switched to ${agentName} agent. You are now the ${agentName} agent. This tool may no longer be available in the new agent.`)
new LanguageModelTextPart(`Switched to ${agentName} agent. You are now the ${agentName} agent. This tool may no longer be available in the new agent.\n\n${planAgentBody}`)
]);
}