Skip to content

Fix delayed cancellation message#27

Merged
jackcbrown89 merged 2 commits into
mainfrom
jb-fix-cancel-msg-delay
Apr 15, 2026
Merged

Fix delayed cancellation message#27
jackcbrown89 merged 2 commits into
mainfrom
jb-fix-cancel-msg-delay

Conversation

@jackcbrown89
Copy link
Copy Markdown
Contributor

@jackcbrown89 jackcbrown89 commented Apr 15, 2026

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 if abort() is called outside an active request or concurrently.

Overview
Fixes client-side cancellation so abort() immediately enqueues a cancel_message to the active transport send queue instead of waiting for the next inbound message.

Refactors query() and execute_commands() to track the current send_queue on the client (self._send_queue) with try/finally cleanup, and shifts cancellation handling to raise CancelledException promptly 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.

… 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.
@jackcbrown89
Copy link
Copy Markdown
Contributor Author

bugbot run

Comment thread packages/runtimeuse-client-python/src/runtimeuse_client/client.py
Ensures self._send_queue is set to None on all exit paths
(CancelledException, AgentRuntimeError, TimeoutError), not just the
normal exit path.
@jackcbrown89
Copy link
Copy Markdown
Contributor Author

bugbot run

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

@jackcbrown89 jackcbrown89 merged commit f7373f8 into main Apr 15, 2026
4 checks passed
@jackcbrown89 jackcbrown89 deleted the jb-fix-cancel-msg-delay branch April 15, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant