feat: redact disabled tools from system prompt (#13597) (#18613)

This commit is contained in:
N. Taylor Mullen
2026-02-10 11:00:36 -08:00
committed by GitHub
parent 740f0e4c3d
commit 55571de066
4 changed files with 113 additions and 75 deletions
@@ -26,6 +26,8 @@ import {
WRITE_TODOS_TOOL_NAME,
READ_FILE_TOOL_NAME,
ENTER_PLAN_MODE_TOOL_NAME,
GLOB_TOOL_NAME,
GREP_TOOL_NAME,
} from '../tools/tool-names.js';
import { resolveModel, isPreviewModel } from '../config/models.js';
import { DiscoveredMCPTool } from '../tools/mcp-tool.js';
@@ -159,6 +161,8 @@ export class PromptProvider {
enableEnterPlanModeTool: enabledToolNames.has(
ENTER_PLAN_MODE_TOOL_NAME,
),
enableGrep: enabledToolNames.has(GREP_TOOL_NAME),
enableGlob: enabledToolNames.has(GLOB_TOOL_NAME),
approvedPlan: approvedPlanPath
? { path: approvedPlanPath }
: undefined,
+24 -3
View File
@@ -54,6 +54,8 @@ export interface PrimaryWorkflowsOptions {
enableCodebaseInvestigator: boolean;
enableWriteTodosTool: boolean;
enableEnterPlanModeTool: boolean;
enableGrep: boolean;
enableGlob: boolean;
approvedPlan?: { path: string };
}
@@ -508,10 +510,29 @@ function workflowStepResearch(options: PrimaryWorkflowsOptions): string {
suggestion = ` For complex tasks, consider using the ${formatToolName(ENTER_PLAN_MODE_TOOL_NAME)} tool to enter a dedicated planning phase before starting implementation.`;
}
if (options.enableCodebaseInvestigator) {
return `1. **Research:** Systematically map the codebase and validate assumptions. Utilize specialized sub-agents (e.g., \`codebase_investigator\`) as the primary mechanism for initial discovery when the task involves **complex refactoring, codebase exploration or system-wide analysis**. For **simple, targeted searches** (like finding a specific function name, file path, or variable declaration), use ${formatToolName(GREP_TOOL_NAME)} or ${formatToolName(GLOB_TOOL_NAME)} directly in parallel. Use ${formatToolName(READ_FILE_TOOL_NAME)} to validate all assumptions. **Prioritize empirical reproduction of reported issues to confirm the failure state.**${suggestion}`;
const searchTools: string[] = [];
if (options.enableGrep) searchTools.push(formatToolName(GREP_TOOL_NAME));
if (options.enableGlob) searchTools.push(formatToolName(GLOB_TOOL_NAME));
let searchSentence =
' Use search tools extensively to understand file structures, existing code patterns, and conventions.';
if (searchTools.length > 0) {
const toolsStr = searchTools.join(' and ');
const toolOrTools = searchTools.length > 1 ? 'tools' : 'tool';
searchSentence = ` Use ${toolsStr} search ${toolOrTools} extensively (in parallel if independent) to understand file structures, existing code patterns, and conventions.`;
}
return `1. **Research:** Systematically map the codebase and validate assumptions. Use ${formatToolName(GREP_TOOL_NAME)} and ${formatToolName(GLOB_TOOL_NAME)} search tools extensively (in parallel if independent) to understand file structures, existing code patterns, and conventions. Use ${formatToolName(READ_FILE_TOOL_NAME)} to validate all assumptions. **Prioritize empirical reproduction of reported issues to confirm the failure state.**${suggestion}`;
if (options.enableCodebaseInvestigator) {
let subAgentSearch = '';
if (searchTools.length > 0) {
const toolsStr = searchTools.join(' or ');
subAgentSearch = ` For **simple, targeted searches** (like finding a specific function name, file path, or variable declaration), use ${toolsStr} directly in parallel.`;
}
return `1. **Research:** Systematically map the codebase and validate assumptions. Utilize specialized sub-agents (e.g., \`codebase_investigator\`) as the primary mechanism for initial discovery when the task involves **complex refactoring, codebase exploration or system-wide analysis**.${subAgentSearch} Use ${formatToolName(READ_FILE_TOOL_NAME)} to validate all assumptions. **Prioritize empirical reproduction of reported issues to confirm the failure state.**${suggestion}`;
}
return `1. **Research:** Systematically map the codebase and validate assumptions.${searchSentence} Use ${formatToolName(READ_FILE_TOOL_NAME)} to validate all assumptions. **Prioritize empirical reproduction of reported issues to confirm the failure state.**${suggestion}`;
}
function workflowStepStrategy(options: PrimaryWorkflowsOptions): string {