Skip to content

[FTRY-1487] A sandbox MCP call with no answer fails after 330 s instead of hanging its thread, by adding a per-call deadline - #92

Open
rbehal wants to merge 3 commits into
mainfrom
rahul-fix-mcp-call-deadline
Open

rbehal wants to merge 3 commits into
mainfrom
rahul-fix-mcp-call-deadline

Conversation

@rbehal

@rbehal rbehal commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Each direct-transport mcp.execute call now has a 330 s deadline, above the backend's tool-call limit, so a lost answer fails instead of hanging its thread.
  • A timeout returns tool_execution_failed; the next call reconnects.
  • Releases 0.5.10, since 0.5.9 is on PyPI.

Test plan

  • Reproduction re-run on the pushed heads: an unanswered call fails at a shortened 20 s deadline, then the next succeeds.
  • pytest tests/sdk/test_gumcp_transport.py: 29 passed.

Exceptions

  • The deadline is a transport safeguard under public-api-clients R2: above the backend limit, no retry.
  • A timeout uses the backend's tool_execution_failed / api_error envelope, not a client-side type (R3).
  • New tests add 3 inline imports and no implementation marker, like the file's other tests.
  • Branch name predates the ticket (existing PR).

Release order: gumloop/gumstack-mcp-python#38, then gumloop/guMCP-client#46, then #92; sandbox versions are raised in gumloop_backend after release.


Raised from Cursor Cloud agent run-9314e1d4

rbehal and others added 3 commits October 28, 2026 23:49
… of hanging its thread

In a sandbox, client.mcp.execute goes through one shared gumcp_client session
on a background loop, and the calling thread waited on it with no deadline.
When a response was lost (a load balancer 502 on one POST tore down the
session in gumstack-mcp 0.1.38), every thread waiting on that session blocked
until the agent's own shell timeout killed the script, with no error.

Each direct-transport call now has a 330 s deadline, above the backend's
300 s per-tool-call limit, so it only ends a call that will never be answered.
It returns the same tool_execution_failed / "Tool call timed out after Ns."
result as the HTTP path and logs a warning. The deadline cancels the hung
call, which makes gumcp_client drop that server's session so the next call
reconnects.

The deadline is asyncio.wait_for rather than an anyio scope: the first call
connects lazily and leaves the session's anyio scopes open in its task, so an
enclosing anyio scope could not exit cleanly. A broken session's "cancel scope"
CancelledError is converted inside the wait_for task so the existing
mcp_server_connection_failed mapping still sees its message on Python 3.10.

Co-authored-by: Cursor <cursoragent@cursor.com>
…gged after the released 0.5.9

The release workflow requires the tag to match _version.py, and v0.5.9 is already on PyPI.

Co-authored-by: Rahul Behal <rahulbehal01@hotmail.com>
…raint each one guards

The 330 s value must stay above the backend's limit and the in-task conversion exists for a Python 3.10/3.11 quirk; the test-double docstrings repeated their code and are removed.

Co-authored-by: Rahul Behal <rahulbehal01@hotmail.com>
@cursor
cursor Bot force-pushed the rahul-fix-mcp-call-deadline branch from 71927d4 to 1c73ef9 Compare October 28, 2026 23:49
@cursor cursor Bot changed the title [Fix] Sandbox MCP calls with no answer fail after 330 s instead of hanging [FTRY-1487] A sandbox MCP call with no answer fails after 330 s instead of hanging its thread, by adding a per-call deadline Oct 28, 2026
@cursor
cursor Bot marked this pull request as ready for review October 28, 2026 23:57

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 3 potential issues.

Devin Review

Comment thread src/gumloop/_gumcp_transport.py Resolved
Comment thread src/gumloop/_gumcp_transport.py Resolved
Comment thread src/gumloop/_gumcp_transport.py Resolved

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants