From 6066b21a6a59d57fb3d6b553b634eee44e1b7f4f Mon Sep 17 00:00:00 2001 From: Correctover Date: Thu, 30 Jul 2026 22:48:49 +0800 Subject: [PATCH] fix: filter disabled MCP tools in registerMcpServer + fix agent timeout description - Fix #2421: registerMcpServer now checks mcpDenyPatterns before registering MCP tools, preventing disabled tools from being added to the tools map unconditionally - Fix #2420: Update agent.md from '30-minute timeout' to '2-hour timeout' to match DEFAULT_SUBAGENT_TIMEOUT_MS constant - Update corresponding test assertion --- packages/agent-core/src/agent/tool/index.ts | 4 ++++ packages/agent-core/src/tools/builtin/collaboration/agent.md | 2 +- packages/agent-core/test/tools/agent.test.ts | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/agent-core/src/agent/tool/index.ts b/packages/agent-core/src/agent/tool/index.ts index 768b48766d..ab9841ec11 100644 --- a/packages/agent-core/src/agent/tool/index.ts +++ b/packages/agent-core/src/agent/tool/index.ts @@ -297,6 +297,10 @@ export class ToolManager { for (const tool of tools) { if (enabledTools !== undefined && !enabledTools.has(tool.name)) continue; const qualified = qualifyMcpToolName(serverName, tool.name); + // Skip tools that are explicitly disabled via the profile's deny patterns + if (this.mcpDenyPatterns.some((pattern) => picomatch.isMatch(qualified, pattern))) { + continue; + } const firstInThisCall = seenInThisCall.get(qualified); if (firstInThisCall !== undefined) { collisions.push({ diff --git a/packages/agent-core/src/tools/builtin/collaboration/agent.md b/packages/agent-core/src/tools/builtin/collaboration/agent.md index ec0533e7ef..d8b65d7c0d 100644 --- a/packages/agent-core/src/tools/builtin/collaboration/agent.md +++ b/packages/agent-core/src/tools/builtin/collaboration/agent.md @@ -9,7 +9,7 @@ Writing the prompt: Usage notes: - When the task continues earlier work a subagent already did, prefer resuming that agent (pass its `resume` id) over spawning a fresh instance — the resumed agent keeps its prior context. - A subagent's result is only visible to you, not to the user. When the user needs to see what a subagent produced, summarize the relevant parts yourself in your own reply. -- Subagents use a fixed 30-minute timeout. If one times out, resume the same agent instead of starting over. +- Subagents use a fixed 2-hour timeout. If one times out, resume the same agent instead of starting over. When NOT to use Agent: skip delegation for trivial work you can do directly — reading a file whose path you already know, searching a small known set of files, or any task that takes only a step or two. Delegation has a context-handoff cost; it pays off only when the task is substantial enough to outweigh it. diff --git a/packages/agent-core/test/tools/agent.test.ts b/packages/agent-core/test/tools/agent.test.ts index 0df5eab03a..daa9de1078 100644 --- a/packages/agent-core/test/tools/agent.test.ts +++ b/packages/agent-core/test/tools/agent.test.ts @@ -128,7 +128,7 @@ describe('AgentTool', () => { const host = mockSubagentHost({ spawn: vi.fn() }); const tool = agentTool(host); - expect(tool.description).toContain('fixed 30-minute timeout'); + expect(tool.description).toContain('fixed 2-hour timeout'); expect(tool.description).not.toContain('operator-configured background timeout'); expect(tool.description).not.toContain('no time limit'); // Background guidance must steer foreground-by-default, so the model doesn't