Skip to content

Comments

feat: add cancel/abort for in-flight LLM requests and tool executions#538

Merged
bug-ops merged 1 commit intomainfrom
feat/cancel-inflight-operations
Feb 18, 2026
Merged

feat: add cancel/abort for in-flight LLM requests and tool executions#538
bug-ops merged 1 commit intomainfrom
feat/cancel-inflight-operations

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Feb 18, 2026

Summary

  • Add two-level cancellation: Arc<Notify> as stable external signal + per-message CancellationToken via tokio-util bridge task
  • Wire tokio::select! with cancellation into agent loop (LLM calls, streaming, native tool processing)
  • Shell executor kills process tree on cancel via kill_process_tree() (prevents zombie grandchildren)
  • CLI: first Ctrl+C cancels current operation, second within 2s triggers full shutdown
  • TUI: Esc in Normal mode cancels active operation with [Esc to cancel] status hint
  • Add ToolError::Cancelled variant and cancellations metric counter

Test plan

  • cargo +nightly fmt --check passes
  • cargo clippy --workspace -- -D warnings passes (0 warnings)
  • cargo nextest run --workspace --lib --bins passes (1598 tests, 9 skipped)
  • Unit tests for shell cancel (exit code 130), process tree kill, signal propagation, multi-message cancel reuse, TUI Esc cancel, metrics counter
  • Manual: verify Esc cancels TUI operation, agent resumes input loop
  • Manual: verify double Ctrl+C in CLI (first cancels, second exits)

Closes #502

…utions

Introduce two-level cancellation scheme using Arc<Notify> as a stable
external signal and per-message CancellationToken via tokio-util bridge.

- Wire cancel into agent loop: call_llm_with_timeout, streaming,
  native tool processing, and tool call handling via tokio::select!
- Add kill_process_tree() for shell executor to prevent zombie
  grandchild processes on cancel (SIGKILL + pkill -P)
- CLI: first Ctrl+C cancels current operation, second within 2s
  triggers full shutdown
- TUI: Esc in Normal mode cancels active operation, status bar
  shows [Esc to cancel] hint during processing
- Add ToolError::Cancelled variant and cancellations metric counter

Closes #502
@bug-ops bug-ops force-pushed the feat/cancel-inflight-operations branch from fc9724f to f165ff0 Compare February 18, 2026 15:40
@bug-ops bug-ops enabled auto-merge (squash) February 18, 2026 15:41
@bug-ops bug-ops merged commit 569a7d0 into main Feb 18, 2026
18 checks passed
@bug-ops bug-ops deleted the feat/cancel-inflight-operations branch February 18, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add cancel/abort for in-flight LLM requests and tool executions

1 participant