From 8f517f5ca66a5e73e0fa0d44bfbb8203fd9e596f Mon Sep 17 00:00:00 2001 From: chelsealong Date: Tue, 25 Aug 2026 13:35:20 +0000 Subject: [PATCH] chore: address AI-review nits on _ever_connected fix Drop the try/except AttributeError guard in the new regression test now that the slot is always defined, and note in the run() comment that _ever_connected is set once and never cleared. --- tests/tools/test_mcp_tool.py | 8 ++------ tools/mcp_tool.py | 1 + 2 files changed, 3 insertions(+), 6 deletions(-) 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":