Skip to content

Comments

Andy/handle task cancellation#2

Open
acarl005 wants to merge 3 commits intomainfrom
andy/handle-task-cancellation
Open

Andy/handle task cancellation#2
acarl005 wants to merge 3 commits intomainfrom
andy/handle-task-cancellation

Conversation

@acarl005
Copy link
Collaborator

@acarl005 acarl005 commented Jan 9, 2026

Handle task cancellation

Adds support for receiving task_cancellation messages from the server via WebSocket and gracefully cancelling running tasks.

Changes

Message types (internal/types/messages.go):

  • Added MessageTypeTaskCancellation and TaskCancellationMessage struct

Worker (internal/worker/worker.go):

  • Handle task_cancellation messages in the WebSocket message handler
  • handleTaskCancellation: looks up the task's cancel function and invokes it
  • executeTask: distinguishes cancellation from genuine failures — cancelled tasks no longer send a TaskFailed message to the server
  • executeTaskInDocker: uses a background context (with timeout) for container cleanup so removal succeeds even when the task context is already cancelled
  • executeTaskInDocker: explicitly stops the running container when the task context is cancelled during ContainerWait

This PR was generated with Oz.

acarl005 and others added 3 commits January 9, 2026 11:35
- Differentiate task cancellation from genuine failures in executeTask;
  cancelled tasks no longer send a TaskFailed message to the server
- Use background context for container cleanup (remove) so it succeeds
  even when the task context is already cancelled
- Explicitly stop the running container when the task context is
  cancelled during ContainerWait, using a background context with timeout

Co-Authored-By: Oz <oz-agent@warp.dev>
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.

2 participants