fix: add onprogress callback to MCP tool calls for timeout renewal#14501
Open
jaried wants to merge 1 commit intoanomalyco:devfrom
Open
fix: add onprogress callback to MCP tool calls for timeout renewal#14501jaried wants to merge 1 commit intoanomalyco:devfrom
jaried wants to merge 1 commit intoanomalyco:devfrom
Conversation
- Add onprogress callback in convertMcpTool to enable progressToken injection - This allows MCP server heartbeat to reset request timeout - Fixes -32001 timeout errors on long-running tool calls (10-20 min) - Add unit test to verify onprogress handler is included in call options Closes anomalyco#14499
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.
Issue for this PR
Closes #14499
Type of change
What does this PR do?
This PR fixes the
-32001timeout error that occurs during long-running MCP tool calls (10~20 minutes) by adding theonprogresscallback to the MCP client'scallTooloptions.Root Cause:
The MCP SDK only injects a
progressTokeninto the request when anonprogresscallback is provided. Without this token:The Fix:
Added a lightweight
onprogress: () => undefinedcallback inconvertMcpToolfunction. This enables:_meta.progressTokeninto the requestresetTimeoutOnProgress: true)Why it works:
The progress token chain is now complete:
onprogresscallback_meta.progressTokeninto requestHow did you verify your code works?
Added unit test
packages/opencode/test/mcp/progress-token.test.tsthat verifies:callTooloptions includeonprogresscallbackresetTimeoutOnProgressis stilltruetimeoutis correctly passed throughTest result: ✅ Pass
Screenshots / recordings
N/A - backend fix
Checklist