fix: reconnect MCP sessions on transient stream failures

maintainer edit: treat transient MCP stream failures as dead sessions so the existing reconnect handler can refresh the session before retrying. Also cover retry failure as a structured tool error.
This commit is contained in:
chengyongru
2026-07-04 21:15:18 +08:00
committed by Xubin Ren
parent 0d1221bece
commit 6d28db3248
2 changed files with 57 additions and 0 deletions
+2
View File
@@ -129,6 +129,8 @@ def _is_transient(exc: BaseException) -> bool:
def _is_session_terminated(exc: BaseException) -> bool:
"""Return True when the MCP SDK reports a dead client session."""
if _is_transient(exc):
return True
messages = [str(exc)]
error = getattr(exc, "error", None)
if error is not None: