Skip to content

Commit 119fb6d

Browse files
committed
Remove dead pending-connection count and cover the plural retry copy
1 parent 80658ad commit 119fb6d

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

‎src/agent/tool-search.test.ts‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,10 @@ describe("createToolSearchTool", () => {
298298
search: (query) => createToolIndex(() => live).search(query),
299299
lookup: (name) => live.find((def) => def.name === name),
300300
promote: () => undefined,
301-
awaitPendingConnections: async (timeoutMs = 50) => {
301+
awaitPendingConnections: async (timeoutMs?: number) => {
302302
await Promise.race([
303303
connected,
304-
new Promise((resolve) => setTimeout(resolve, timeoutMs)),
304+
new Promise((resolve) => setTimeout(resolve, timeoutMs ?? 50)),
305305
]);
306306
return live.length === 0 ? 1 : 0;
307307
},
@@ -335,6 +335,19 @@ describe("createToolSearchTool", () => {
335335
expect(out).not.toContain("different keywords");
336336
});
337337

338+
test("two pending connectors report the plural connecting copy", async () => {
339+
const tool = createToolSearchTool({
340+
search: () => [],
341+
lookup: () => undefined,
342+
promote: () => undefined,
343+
awaitPendingConnections: async () => 2,
344+
});
345+
const out = await call(tool, { query: "linear" });
346+
expect(out).toContain("2 connectors are still connecting");
347+
expect(out).toMatch(/retry.*shortly/i);
348+
expect(out).not.toContain("different keywords");
349+
});
350+
338351
test("a genuine miss keeps the keyword advice and omits the retry caveat", async () => {
339352
const tool = createToolSearchTool({
340353
search: () => [],

‎src/agent/tools.ts‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,6 @@ export interface AgentToolset {
323323
// second add of an active name; failed rows retry through connectMCPServer
324324
// without a second persist. Still true while disable is in progress.
325325
hasMCPServer: (name: string) => boolean;
326-
// Live MCP handshake depth: non-zero while any server is still connecting.
327-
// tool_search consults this on a miss — waiting briefly and reporting a
328-
// retry signal instead of a definitive negative mid-handshake.
329-
pendingMcpConnectionCount: () => number;
330326
// Bounded wait for in-flight MCP handshakes; resolves to the remaining
331327
// count. Capped by `timeoutMs` so a hung authorization never hangs the
332328
// caller — the tool_search bound passes briefly by default.
@@ -762,10 +758,6 @@ export async function createAgentToolset(
762758
const connectedClients = new Map<string, MCPClient>();
763759
const inFlightConnections = new Map<string, Promise<void>>();
764760
const inFlightEpochs = new Map<string, number>();
765-
// Live handshake depth for tool_search: a miss waits briefly for these
766-
// before answering, so a mid-handshake search finds late-mounting tools
767-
// instead of reporting a definitive negative.
768-
const pendingMcpConnectionCount = (): number => inFlightConnections.size;
769761
// Bounded wait for in-flight handshakes; resolves to the remaining count.
770762
// Capped by `timeoutMs` so a hung authorization never hangs the caller.
771763
const awaitPendingMcpConnections = async (
@@ -1260,7 +1252,6 @@ export async function createAgentToolset(
12601252
disconnectMCPServer: publicDisconnectMCPServer,
12611253
hasMCPServer: (name) =>
12621254
connectedClients.has(name) || inFlightConnections.has(name),
1263-
pendingMcpConnectionCount,
12641255
awaitPendingMcpConnections,
12651256
setMcpServersSource: (source) => {
12661257
mcpServersSource = source;

0 commit comments

Comments
 (0)