feat: add cancel/abort for in-flight LLM requests and tool executions#538
Merged
feat: add cancel/abort for in-flight LLM requests and tool executions#538
Conversation
…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
fc9724f to
f165ff0
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
Arc<Notify>as stable external signal + per-messageCancellationTokenvia tokio-util bridge tasktokio::select!with cancellation into agent loop (LLM calls, streaming, native tool processing)kill_process_tree()(prevents zombie grandchildren)[Esc to cancel]status hintToolError::Cancelledvariant andcancellationsmetric counterTest plan
cargo +nightly fmt --checkpassescargo clippy --workspace -- -D warningspasses (0 warnings)cargo nextest run --workspace --lib --binspasses (1598 tests, 9 skipped)Closes #502