fix: reconnect stale MCP sessions before retry - #27052
Conversation
This comment was marked as spam.
This comment was marked as spam.
|
Thanks for the focused MCP recovery fix. I agree the premise still exists on current main: Problems
Suggested changes
This is an automated hermes-sweeper review. |
|
Salvaged into PR #59331 (merged) — your commit was cherry-picked onto current main with your authorship preserved in git log (43a4256). Your diagnosis was the only one in this cluster that survived the recent reconnect-resilience overhaul: |
Summary
Fixes stale MCP HTTP/stream session recovery for long-lived Hermes sessions. When an MCP server reports a session-expired / auth-recovery style failure, the retry path now clears readiness, signals reconnect, waits for a distinct fresh session, and avoids counting short reconnect windows as circuit-breaker failures.
This specifically addresses gateway/live-session cases where a fresh CLI
hermes mcp test <server>succeeds while a long-lived chat process keeps retrying against a stale MCP session and surfaces errors such asSession terminated,not connected, orunreachable after consecutive failures.Changes
Verification
Local verification already run before opening this PR:
Post-gateway-restart live smoke from the affected Telegram profile also passed:
mcp_hindsight_get_banksucceeded.mcp_hindsight_recallsucceeded.mcp_hindsight_list_operationssucceeded.Risk
Medium-low. This changes reconnect/retry behavior for MCP transports, but the patch is covered by focused stale-session and circuit-breaker regression tests. The intended behavior is only to force a genuinely fresh session before retrying after session-expired/auth-recovery failures, rather than reusing a stale one.