ToolRegistry.execute() catches Exception, but asyncio.CancelledError#1743
Open
pixan-ai wants to merge 1 commit intoHKUDS:mainfrom
Open
ToolRegistry.execute() catches Exception, but asyncio.CancelledError#1743pixan-ai wants to merge 1 commit intoHKUDS:mainfrom
pixan-ai wants to merge 1 commit intoHKUDS:mainfrom
Conversation
inherits from BaseException (Python 3.9+), so it escapes unhandled. Adding an explicit re-raise ensures /stop task cancellation propagates correctly through the tool execution layer.
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.
What
Add explicit
asyncio.CancelledErrorhandling inToolRegistry.execute().Why
ToolRegistry.execute()wraps tool calls intry/except Exception, butasyncio.CancelledErrorinherits fromBaseException(notException)since Python 3.9. This means task cancellations from
/stopescape thehandler without being properly propagated.
This is the registry-level counterpart to the MCP tool-level fix in PR #1728.
How
except asyncio.CancelledError: raisebefore theexcept Exceptionhandler/stopcancellations propagate correctly through tool executionTesting
/stop→ should cancel cleanlyAcknowledgment
Fix identified and developed with assistance from Claude Opus 4.6