feat(Chat): interrupt agent execution#39
Merged
remarkablemark merged 7 commits intomasterfrom May 9, 2026
Merged
Conversation
Pressing Esc or Ctrl+C while the agent is streaming or executing a tool
cancels the in-flight operation, commits any partial assistant content
already accumulated, shows a UI-only interrupt notice, injects a
user-role `turn_aborted` message into history, and returns to the idle
input state.
Two things happen on interrupt:
1. **UI notice** (display-only, not in history):
> `❗ Execution interrupted.`
> Rendered via a transient `wasInterrupted` boolean state; disappears on next submit.
2. **History injection** (model sees it, as a `user` role message):
```
<turn_aborted>
The user interrupted the previous turn on purpose. Any running commands may still be running in the background. If any tools were aborted, they may have partially executed.
</turn_aborted>
```
Appended to `messages` state so the model knows not to assume success.
In `handleToolApproval` `DECISION.REJECT` case: replace the current
`system`-role `"User declined to execute tool {name}"` message with a
`user`-role `<turn_aborted>` message (same text as the interrupt).
Rejecting a tool call now displays a rejection message and returns directly to idle — no re-stream, no repeated approval prompt.
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
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.
What is the motivation for this pull request?
Implement interrupt functionality during agent/tool execution, similar to other TUIs.
What is the current behavior?
There is no way to cancel a running stream or reject a tool call and return to idle.
What is the new behavior?
AbortSignaland shows❗ Execution interrupted.❗ Tool call rejected.instead of re-streaming<turn_aborted>user-role message is injected into history on both interrupt and rejection so the model has context, but it is filtered from the UIMessagesmoved to its ownsrc/components/Messages/directory with aconstants.tsforTURN_ABORTED_MESSAGEexternallist removed — Vite SSR mode auto-externalises all dependenciesChecklist: