diff --git a/tests/tools/test_mcp_tool.py b/tests/tools/test_mcp_tool.py index 46ddf6db45..046b303d42 100644 --- a/tests/tools/test_mcp_tool.py +++ b/tests/tools/test_mcp_tool.py @@ -1444,15 +1444,11 @@ class TestReconnection: if run_count == 1: # Initial connection succeeds and registers tools. Setting # ``_ever_connected`` mirrors what the real ``_run_stdio`` - # does right after a successful ``_discover_tools()`` call; - # guarded because the pre-fix class has no such slot. + # does right after a successful ``_discover_tools()`` call. self_srv.session = MagicMock() self_srv._tools = [] self_srv._ready.set() - try: - self_srv._ever_connected = True - except AttributeError: - pass + self_srv._ever_connected = True return "reconnect" if run_count <= 5: # Four consecutive failures on later reconnect attempts -- diff --git a/tools/mcp_tool.py b/tools/mcp_tool.py index 4f9078aaaa..c1c80e5adb 100644 --- a/tools/mcp_tool.py +++ b/tools/mcp_tool.py @@ -4133,6 +4133,7 @@ class MCPServerTask: # that already registered tools once and then dropped would # otherwise be misclassified as never having connected and # re-enter this initial-connect ladder (#94654). + # ``_ever_connected`` itself is set once and never cleared. # (Ported from Kilo Code's MCP resilience fix.) if not self._ever_connected: if failure_class == "permanent":