Skip to content

Implement real remote cancellation for driver cancel_task #9

Description

@yzs15

Background

PR #8 makes delegated task IDs recoverable after MCP client timeout/interruption by recording them in the driver task journal and exposing list_driver_tasks. That closes the recover/poll path, but it does not make long-running remote tasks cancellable.

Today driver cancel_task is still a stub: it can report current status, but it does not propagate cancellation to agentserver or the target slave. If a caller times out or intentionally aborts after recovering a task_id, the only supported follow-up is polling/inspection, not cancellation.

Problem

A long-running delegated task can continue running after the original MCP client has timed out or been interrupted. Recovering the task_id is useful, but operators also need a way to stop the remote work when it is no longer wanted.

Proposed Scope

Implement real cancellation semantics for driver cancel_task:

  • Add or use an agentserver API that marks a delegated task as cancelled.
  • Propagate cancellation to the executing agent/slave when possible.
  • Make cancel_task return a clear result for:
    • cancellation requested successfully
    • task already terminal
    • task not found
    • backend/target does not support interruption
  • Ensure get_task/wait_task surface the cancelled terminal state consistently.

Acceptance Criteria

  • cancel_task can stop a running delegated shell task in an e2e/prod_test-style flow.
  • A cancelled task reaches a terminal cancelled status instead of continuing until normal completion.
  • Calling cancel_task on completed/failed/cancelled tasks is idempotent and returns a clear message.
  • Tests cover driver tool behavior and the server/agent cancellation path.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions