fix: catch BaseException in MCP connection to handle CancelledError

This commit is contained in:
chengyongru
2026-03-13 10:23:15 +08:00
parent 774452795b
commit 127ac39063

View File

@@ -139,7 +139,7 @@ class AgentLoop:
await self._mcp_stack.__aenter__()
await connect_mcp_servers(self._mcp_servers, self.tools, self._mcp_stack)
self._mcp_connected = True
except Exception as e:
except BaseException as e:
logger.error("Failed to connect MCP servers (will retry next message): {}", e)
if self._mcp_stack:
try: