fix(mcp): report configured timeout in MCP call errors#21281
Merged
Conversation
Track elapsed wall time in _run_on_mcp_loop, cancel the in-flight future when a timeout expires, and raise a descriptive TimeoutError that includes the elapsed and configured timeout. Add regression coverage for the new timeout diagnostics.
Contributor
🔎 Lint report:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Salvage of #10439 by @masonjames onto current main. Cherry-picked clean.
Summary
When an MCP call exceeds its configured timeout, the error now reports both the wall-clock elapsed time and the configured timeout. Previously the timeout path returned
future.result(timeout=0)which raises a bareconcurrent.futures.TimeoutErrorwith an empty string — the model saw a silent failure with no context.Also cancels the in-flight future on timeout so the coroutine doesn't keep running in the background after the caller gives up.
Before / after
str(exc)''TimeoutError()MCP call timed out after 30.0s (configured timeout: 30.0s)Changes
tools/mcp_tool.py_run_on_mcp_loop: trackstart_time, cancel future on timeout, raise descriptiveTimeoutError. +8 / -2.tests/tools/test_mcp_tool.py: +37 lines of timeout-diagnostics regression coverage.scripts/release.py: AUTHOR_MAP entry for @masonjames.Validation
scripts/run_tests.sh tests/tools/test_mcp_tool.pyTimeoutError: MCP call timed out after 0.3s (configured timeout: 0.3s), wall-clock elapsed 0.30sfuture.result(timeout=0)patternTimeoutError()with empty message — confirms bug was realCloses #10439. @masonjames's authorship preserved via rebase-merge.