From 339c836a4264247b71d824fae333b2602c5a94db Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Tue, 25 Mar 2025 14:21:31 -0400 Subject: [PATCH] Auto-approval logic for fetch_instructions --- .../prompts/__tests__/__snapshots__/system.test.ts.snap | 8 ++------ src/core/prompts/sections/mcp-servers.ts | 4 +--- src/core/prompts/sections/modes.ts | 2 +- webview-ui/src/components/chat/ChatView.tsx | 9 +++++++++ 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/core/prompts/__tests__/__snapshots__/system.test.ts.snap b/src/core/prompts/__tests__/__snapshots__/system.test.ts.snap index e7f5e5c3ab..2b869ee26e 100644 --- a/src/core/prompts/__tests__/__snapshots__/system.test.ts.snap +++ b/src/core/prompts/__tests__/__snapshots__/system.test.ts.snap @@ -3358,9 +3358,7 @@ When a server is connected, you can use the server's tools via the \`use_mcp_too (No MCP servers currently connected) ## Creating an MCP Server -The user may ask you something along the lines of "add a tool" that does some function, in other words to create an MCP server that provides tools and resources that may connect to external APIs for example. You have the ability to create an MCP server and add it to a configuration file that will then expose the tools and resources for you to use with \`use_mcp_tool\` and \`access_mcp_resource\`. - -You can obtain detailed instructions on this topic using the fetch_instructions tool, like this: +The user may ask you something along the lines of "add a tool" that does some function, in other words to create an MCP server that provides tools and resources that may connect to external APIs for example. If they do, you should obtain detailed instructions on this topic using the fetch_instructions tool, like this: create_mcp_server @@ -6671,9 +6669,7 @@ When a server is connected, you can use the server's tools via the \`use_mcp_too (No MCP servers currently connected) ## Creating an MCP Server -The user may ask you something along the lines of "add a tool" that does some function, in other words to create an MCP server that provides tools and resources that may connect to external APIs for example. You have the ability to create an MCP server and add it to a configuration file that will then expose the tools and resources for you to use with \`use_mcp_tool\` and \`access_mcp_resource\`. - -You can obtain detailed instructions on this topic using the fetch_instructions tool, like this: +The user may ask you something along the lines of "add a tool" that does some function, in other words to create an MCP server that provides tools and resources that may connect to external APIs for example. If they do, you should obtain detailed instructions on this topic using the fetch_instructions tool, like this: create_mcp_server diff --git a/src/core/prompts/sections/mcp-servers.ts b/src/core/prompts/sections/mcp-servers.ts index 5603b0c385..7062276657 100644 --- a/src/core/prompts/sections/mcp-servers.ts +++ b/src/core/prompts/sections/mcp-servers.ts @@ -69,9 +69,7 @@ ${connectedServers}` ` ## Creating an MCP Server -The user may ask you something along the lines of "add a tool" that does some function, in other words to create an MCP server that provides tools and resources that may connect to external APIs for example. You have the ability to create an MCP server and add it to a configuration file that will then expose the tools and resources for you to use with \`use_mcp_tool\` and \`access_mcp_resource\`. - -You can obtain detailed instructions on this topic using the fetch_instructions tool, like this: +The user may ask you something along the lines of "add a tool" that does some function, in other words to create an MCP server that provides tools and resources that may connect to external APIs for example. If they do, you should obtain detailed instructions on this topic using the fetch_instructions tool, like this: create_mcp_server ` diff --git a/src/core/prompts/sections/modes.ts b/src/core/prompts/sections/modes.ts index 4f79d9dc9d..12e90c4076 100644 --- a/src/core/prompts/sections/modes.ts +++ b/src/core/prompts/sections/modes.ts @@ -24,7 +24,7 @@ ${allModes.map((mode: ModeConfig) => ` * "${mode.name}" mode (${mode.slug}) - $ // Only include custom modes documentation if the feature is enabled if (shouldEnableCustomModeCreation) { modesContent += ` -If the user asks you to create or edit a new mode for this project, you can get instructions using the fetch_instructions tool, like this: +If the user asks you to create or edit a new mode for this project, you should read the instructions by using the fetch_instructions tool, like this: create_mode diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index 54e5e478da..4075485732 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -676,6 +676,15 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie return false } + if (tool?.tool === "fetchInstructions") { + if (tool.content === "create_mode") { + return alwaysAllowModeSwitch + } + if (tool.content === "create_mcp_server") { + return alwaysAllowMcp + } + } + if (tool?.tool === "switchMode") { return alwaysAllowModeSwitch }