Backport abandoned-request resolution from 2.x to the 1.x Streamable HTTP client by zgj-ssslab · Pull Request #3444 · modelcontextprotocol/python-sdk · GitHub
Skip to content

Backport abandoned-request resolution from 2.x to the 1.x Streamable HTTP client - #3444

Closed
zgj-ssslab wants to merge 1 commit into
modelcontextprotocol:v1.xfrom
zgj-ssslab:backport/resolve-abandoned-request-v1.x
Closed

zgj-ssslab wants to merge 1 commit into
modelcontextprotocol:v1.xfrom
zgj-ssslab:backport/resolve-abandoned-request-v1.x

Conversation

@zgj-ssslab

Copy link
Copy Markdown

Summary

On the 1.x line (v1.29.x, and the v1.x branch), a pending request stays unresolved forever when:

  • the server answers its POST with 202 Accepted,
  • the per-request SSE stream ends without carrying a response event, or
  • reconnection attempts are exhausted.

The caller only learns of the failure when its own deadline fires, and it surfaces as a timeout rather than a disconnect.

Fix

Port the _resolve_abandoned_request mechanism from 2.x (#3047, shipped in v2.0.0) to the 1.x StreamableHTTPTransport, adapted to the 1.x root-model message API:

  • a request answered with 202 Accepted is resolved with INVALID_REQUEST;
  • an SSE stream that ends without a response event and cannot be resumed is resolved with CONNECTION_CLOSED;
  • exhausted reconnection attempts resolve with CONNECTION_CLOSED;
  • notifications are not affected (they have no waiter to resolve).

How I checked

  • 4 new deterministic unit tests in tests/client/test_streamable_http_abandoned_request.py (no network, no real server): the three resolution paths above, plus a guard that a 202 for a notification injects nothing
  • Full tests/shared/test_streamable_http.py suite passes (58 tests), including test_streamable_http_multiple_reconnections

Fixes #3441

…HTTP client

On the 1.x line, a pending request stays unresolved forever when the
server answers its POST with 202 Accepted, when the per-request SSE
stream ends without carrying a response event, or when reconnection
attempts are exhausted: the caller only learns of the failure when its
own deadline fires, and it surfaces as a timeout rather than a
disconnect.

Port the _resolve_abandoned_request mechanism from 2.x (PR modelcontextprotocol#3047) to
the 1.x StreamableHTTPTransport: resolve the pending request with a
synthesized JSONRPCError (CONNECTION_CLOSED, or INVALID_REQUEST for the
202 case) at the three sites where its response can never arrive.
Notifications are not affected.

Fixes modelcontextprotocol#3441
@github-actions github-actions Bot added the missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md) label Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant