fix(mcp): stop retrying wrapped OAuth failures - #62025
Draft
luckymikey999-coder wants to merge 1 commit into
Draft
fix(mcp): stop retrying wrapped OAuth failures#62025luckymikey999-coder wants to merge 1 commit into
luckymikey999-coder wants to merge 1 commit into
Conversation
Collaborator
Contributor
|
Thanks for the focused regression fix. Current main still has the reported classifier gap: The tests cover nested and mixed groups, preserve the HTTP 401/500 distinction, and update the existing startup-retry integration test without mocking the classifier. This appropriately extends the top-level auth short-circuit introduced by Automated hermes-sweeper review. |
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.
Summary
BaseExceptionGroup/ExceptionGroupinstances as terminal auth failuresRoot cause
The MCP SDK's async transport can wrap
OAuthNonInteractiveError("user_skipped")in anExceptionGroup._is_auth_error()only inspected the top-level exception, soMCPServerTask.run()misclassified the wrapped auth abort as a transient connection failure.That reran the whole transport four times (initial attempt plus three configured retries), producing repeated authorization URLs/browser prompts. After the retry budget was exhausted, the task parked for reconnect; cancellation during that parked wait reproduced the reported
RuntimeError: Event loop is closedcleanup traceback.This change recursively classifies a group as auth-related when any nested leaf is already auth-related. The original group is preserved in
server._error; the change only prevents automatic restart of an interactive auth flow. Direct HTTP policy remains unchanged: 401 is auth-related, 500 is not.Reference behavior
OpenCode represents authorization-required as an explicit terminal MCP state rather than a generic transport retry. Qwen Code similarly excludes auth failures from generic transient retry policy and owns a single callback-server lifecycle.
Tests
Relevant suites after rebasing onto current
origin/main:10 passed, 3 deselected— focused wrapped-auth/classifier matrix withPytestUnraisableExceptionWarningpromoted to error373 passed— MCP tool, OAuth, OAuth manager, and CLI MCP config modulesruff check— passed for all touched filesgit diff --check— passedA full repository xdist run completed with
39656 passed, 226 skipped, 536 failed, 18 errorsin 12m51s. The failures/errors are broad pre-existing environment/global-state failures (including web-provider, Hindsight, and website-policy suites); all touched and directly relevant MCP/OAuth/CLI modules are green.No live OAuth provider, browser callback, credentials, config, gateway, or runtime rollout was used or changed.