feat: add POST /v1/cancel/{command_id} endpoint#1579
Merged
Evanev7 merged 3 commits intoexo-explore:mainfrom Mar 3, 2026
Merged
feat: add POST /v1/cancel/{command_id} endpoint#1579Evanev7 merged 3 commits intoexo-explore:mainfrom
Evanev7 merged 3 commits intoexo-explore:mainfrom
Conversation
Evanev7
requested changes
Feb 21, 2026
Comment on lines
+569
to
+571
| async def cancel_command(self, command_id: str) -> CancelCommandResponse: | ||
| """Cancel an active command by closing its stream and notifying workers.""" | ||
| cid = CommandId(command_id) |
Member
There was a problem hiding this comment.
Suggested change
| async def cancel_command(self, command_id: str) -> CancelCommandResponse: | |
| """Cancel an active command by closing its stream and notifying workers.""" | |
| cid = CommandId(command_id) | |
| async def cancel_command(self, command_id: CommandId) -> CancelCommandResponse: | |
| """Cancel an active command by closing its stream and notifying workers.""" |
Member
There was a problem hiding this comment.
the CommandId's are just strings anyway, we don't need the extra step here
Evanev7
approved these changes
Feb 21, 2026
Member
Evanev7
left a comment
There was a problem hiding this comment.
cool, test seems a little redundant imo but lgtm
27884fb to
26dfbf2
Compare
Contributor
Author
|
What did you do @Evanev7 |
Member
|
just rebased onto latest main to try and get it merged, though we're feature freezing now before our next release |
Contributor
Author
Sorry for confusion |
Member
|
no worries! it's nice to see regular contributors so let me know if i can do anything to keep things clear |
Contributor
Author
Thank you 🙏🙏 |
…cancellation Previously, generation cancellation only worked via HTTP disconnect (client closes SSE connection). This adds an explicit REST endpoint so non-streaming clients and external consumers can cleanly cancel in-flight text and image generation commands by ID.
3f7c378 to
35b8b1d
Compare
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
POST /v1/cancel/{command_id}REST endpoint to cancel in-flight text and image generation commands by IDanyio.get_cancelled_exc_class()). Non-streaming clients and external consumers had no way to cleanly cancel active generationTaskCancelledto notify workers, and closes the sender stream. Returns 404 (OpenAI error format) if the command is not found or already completedChanges
src/exo/shared/types/api.pyCancelCommandResponsemodelsrc/exo/master/api.pycancel_commandhandlersrc/exo/master/tests/test_cancel_command.pydocs/api.mdDesign Decisions
self._send()(not rawcommand_sender.send()) — respects API pause state during electionsraise HTTPException— feeds into exo's centralized OpenAI-style error handlerCancelCommandResponse— consistent withCreateInstanceResponse/DeleteInstanceResponsepatternssender.close()is idempotent so concurrent cancel requests for the same command are harmlessTest Plan
test_cancel_nonexistent_command_returns_404— verifies 404 with OpenAI error formattest_cancel_active_text_generation— verifies 200,sender.close()called,TaskCancelledsent with correctcancelled_command_idtest_cancel_active_image_generation— same verification for image queuebasedpyright— 0 new errorsruff check— all checks passedpytest— 3/3 new tests pass, no regressions