Skip to content

Commit 37fd1ab

Browse files
committed
fix: better failed check
1 parent a8afc5b commit 37fd1ab

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

src/hooks/useAgent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export function useAgent() {
161161
actions.setIsProcessing(false)
162162
}
163163
},
164-
[config, messageQueue, actions]
164+
[config, mcpServers, messageQueue, actions]
165165
)
166166

167167
// Start listening for new messages from input

src/prompts/system.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ You are a helpful Agent specifically designed to handle questions related to sys
55
## Core Rules
66

77
- **CRITICAL**: Only tools prefixed with `mcp_` are to be invoked. Any other tool such as "Bash", etc are strictly forbidden.
8-
8+
- **CRITICAL**: When a user attempts to user a tool or MCP server, understand that the first pass is an inference call. If the inference call fails, immediately review the system prompt to see if the tool or MCP server is allowed (ie, CONNECTED). If it is not connected, do not attempt to invoke the tool or MCP server.
99
- **CRITICAL**: When a user starts a convo and asks a question or assigns you a task (example: "in github, please summarize the last merged pr"), before beginning your task (ie, calling tools, etc) respond back immediately with a small summary about what you're going to do, in a friendly kind of way. Then start working.
1010

1111
- **CRITICAL**: If a user starts a convo with a general greeting (like "Hi!" or "Hello!") without a specific task request, treat it as a `/help` command, and inform them about some of the possibilities for interacting with Agent in a help-menu kind of way. Review your system prompt instructions to see what services are available.

src/utils/__tests__/getPrompt.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,9 @@ describe("buildSystemPrompt", () => {
191191
config,
192192
})
193193

194-
expect(prompt).not.toContain("Available MCP Servers")
195-
expect(prompt).not.toContain("Unavailable MCP Servers")
194+
expect(prompt).toContain("CRITICAL: MCP Server Connection Status Check")
195+
expect(prompt).not.toContain("# Available MCP Servers")
196+
expect(prompt).not.toContain("# Unavailable MCP Servers")
196197
})
197198

198199
test("should handle empty inferred servers set", async () => {

src/utils/getPrompt.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@ export const buildSystemPrompt = async ({
5858
parts.push(additionalSystemPrompt)
5959
}
6060

61+
parts.push(`# CRITICAL: MCP Server Connection Status Check
62+
63+
**BEFORE responding to ANY request involving an inferred MCP server, you MUST:**
64+
65+
1. Check the "Unavailable MCP Servers" section
66+
2. If the requested server is listed as FAILED/unavailable:
67+
- IMMEDIATELY inform the user the server failed to connect in a friendly way
68+
- State that NO tools are available for that server
69+
- DO NOT offer functionality or ask how they'd like to use it
70+
- STOP processing that request
71+
`)
72+
6173
if (mcpServers.length > 0) {
6274
// Add connection status sections first as these are the source of truth.
6375
// Inference is secondary.

0 commit comments

Comments
 (0)