mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
fix(mcp): retry stale pipe transport failures
Treat closed-resource, closed-transport, broken-pipe, and EOF MCP failures as stale session equivalents so the existing reconnect/retry-once path can recover. Add regression coverage for the stale-pipe marker variants.\n\nChecks:\n- python -m py_compile tools/mcp_tool.py tests/tools/test_mcp_tool_session_expired.py\n- python -m pytest tests/tools/test_mcp_tool_session_expired.py -q -o addopts=\n- selected secret scan over touched files
This commit is contained in:
parent
8ad117a3d6
commit
a1f85ef2b9
2 changed files with 17 additions and 0 deletions
|
|
@ -53,6 +53,17 @@ def test_is_session_expired_detects_session_terminated():
|
|||
assert _is_session_expired_error(RuntimeError("Session terminated")) is True
|
||||
|
||||
|
||||
def test_is_session_expired_detects_stale_pipe_and_closed_transport_variants():
|
||||
"""Stdio/AnyIO stale-pipe failures usually surface as closed-resource
|
||||
or broken-pipe text, not an HTTP session-expired JSON-RPC error."""
|
||||
from tools.mcp_tool import _is_session_expired_error
|
||||
assert _is_session_expired_error(RuntimeError("ClosedResourceError")) is True
|
||||
assert _is_session_expired_error(RuntimeError("closed resource in MCP child")) is True
|
||||
assert _is_session_expired_error(RuntimeError("transport is closed")) is True
|
||||
assert _is_session_expired_error(RuntimeError("Broken pipe while writing request")) is True
|
||||
assert _is_session_expired_error(RuntimeError("End of file from MCP server")) 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."""
|
||||
|
|
|
|||
|
|
@ -1739,6 +1739,12 @@ _SESSION_EXPIRED_MARKERS: tuple = (
|
|||
"session not found",
|
||||
"unknown session",
|
||||
"session terminated",
|
||||
"closedresourceerror",
|
||||
"closed resource",
|
||||
"transport is closed",
|
||||
"connection closed",
|
||||
"broken pipe",
|
||||
"end of file",
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue