Skip to content

Implement cancellation token propagation for ACP sessions #780

@bug-ops

Description

@bug-ops

Parent Epic

#777

Problem

cancel() is currently a no-op. The agent loop continues running after IDE sends cancel, wasting resources and blocking the session.

Solution

  • Add CancellationToken (tokio-util) to SessionEntry
  • Create token on new_session, store in session map
  • cancel() calls token.cancel()
  • Agent loop checks token.is_cancelled() between LLM calls and tool executions
  • prompt() drain loop selects on token cancellation, returns StopReason::Cancelled
  • Wire through LoopbackChannel or as separate signal

Critical Path

Depends on: #779 (AcpContext wiring — agent loop must be ACP-aware)
Blocks: nothing directly, but required for responsive IDE UX

Acceptance Criteria

  • CancellationToken stored per session
  • cancel() triggers token
  • Agent loop exits promptly on cancellation
  • prompt() returns StopReason::Cancelled
  • Integration test: prompt → cancel → verify cancelled response

Metadata

Metadata

Assignees

No one assigned

    Labels

    acpAgent Client Protocol integrationenhancementNew feature or requestsize/M

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions