diff --git a/tests/tools/test_mcp_tool_session_expired.py b/tests/tools/test_mcp_tool_session_expired.py index 67e6e58741..4533282e70 100644 --- a/tests/tools/test_mcp_tool_session_expired.py +++ b/tests/tools/test_mcp_tool_session_expired.py @@ -46,6 +46,13 @@ def test_is_session_expired_detects_session_not_found(): assert _is_session_expired_error(RuntimeError("Unknown session: abc123")) is True +def test_is_session_expired_detects_session_terminated(): + """Remote Playwright MCP reports transport loss as ``Session terminated``.""" + from tools.mcp_tool import _is_session_expired_error + + assert _is_session_expired_error(RuntimeError("Session terminated")) is True + + def test_is_session_expired_is_case_insensitive(): """Match uses lower-cased comparison so servers that emit the message in different cases (SDK formatter quirks) still trigger.""" diff --git a/tools/mcp_tool.py b/tools/mcp_tool.py index 2a0115ec85..21e935a12f 100644 --- a/tools/mcp_tool.py +++ b/tools/mcp_tool.py @@ -1667,6 +1667,7 @@ _SESSION_EXPIRED_MARKERS: tuple = ( "session expired", "session not found", "unknown session", + "session terminated", )