fix(evolution): prevent MCP tool re-injection into restricted review agent #2904

This commit is contained in:
zhayujie
2026-06-20 15:17:11 +08:00
parent a0e20ef311
commit 0bc0f2b930
2 changed files with 15 additions and 0 deletions

View File

@@ -523,6 +523,16 @@ class ToolManager:
if agent is None or not hasattr(agent, "tools"):
return ([], [])
# Never re-inject MCP tools into a restricted Self-Evolution review agent.
# The review agent is created with a deliberately reduced, workspace-guarded
# toolset; silently re-adding configured MCP tools here would bypass that
# policy boundary (see agent/evolution/executor.py). The flag may live on
# the agent itself (Agent) or on the wrapping stream executor's .agent.
if getattr(agent, "_evolution_restricted", False) or getattr(
getattr(agent, "agent", None), "_evolution_restricted", False
):
return ([], [])
from agent.tools.mcp.mcp_tool import McpTool
current = self._mcp_tool_instances
registry_names = set(current.keys())