Fix delayed cancellation message#27
Merged
Merged
Conversation
… received message Previously, the cancel message was only sent to the server when the next incoming message arrived in the async for loop. If the agent was busy and not sending messages, the cancel sat unsent indefinitely. Now abort() puts the cancel message directly on the send queue so the transport sends it over WebSocket right away.
Contributor
Author
|
bugbot run |
Ensures self._send_queue is set to None on all exit paths (CancelledException, AgentRuntimeError, TimeoutError), not just the normal exit path.
Contributor
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 93107d4. Configure here.
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.
Send cancel message immediately on abort instead of deferring to next received message
Previously, the cancel message was only sent to the server when the next incoming message arrived in the async for loop. If the agent was busy and not sending messages, the cancel sat unsent indefinitely. Now abort() puts the cancel message directly on the send queue so the transport sends it over WebSocket right away.
Note
Medium Risk
Touches async control flow and shared state (
self._send_queue) in the request/response loop; could introduce edge cases ifabort()is called outside an active request or concurrently.Overview
Fixes client-side cancellation so
abort()immediately enqueues acancel_messageto the active transport send queue instead of waiting for the next inbound message.Refactors
query()andexecute_commands()to track the currentsend_queueon the client (self._send_queue) withtry/finallycleanup, and shifts cancellation handling to raiseCancelledExceptionpromptly when the abort event is set.Reviewed by Cursor Bugbot for commit 93107d4. Bugbot is set up for automated code reviews on this repo. Configure here.