anomalyco / anomalyco/opencode
Session abort waits for a model-invoked bash tool to finish
@nexxeln is already working on this.
Since Aug 6, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
What happened
When a model invokes a long-running built-in bash tool, aborting the session does not stop the command promptly. The session receives the abort request, but the bash tool keeps running, the session remains busy, and the abort request waits until the command exits naturally. The tool is only then finalized as Tool execution aborted.
In a local reproduction, the abort request was sent about 13 seconds after sleep 30 began. Three seconds later the session was still busy, and the request returned only after the remaining sleep time elapsed.
Expected behavior
Abort should immediately propagate to the active tool, terminate its child process, return promptly, and move the session to idle.
Suspected area
The timing suggests a cancellation-ordering issue: the model stream waits for the tool Promise, while the tool abort signal is not triggered until the stream is released. As a result, cancellation reaches the tool after the command has already completed.
Related reports: #40468, #20094, #21743, and #29894.
Plugins
Custom plugins were enabled, but the reproduction uses OpenCode's built-in bash tool and standard session abort route. No plugin behavior is required.
OpenCode version
Local development build based on OpenCode v1.18.13; the relevant cancellation path matches upstream dev.
Steps to reproduce
- Start
opencode serveoropencode web. - Ask the model: "Only call bash and run
sleep 30in the foreground. Wait for it to finish before replying." - Wait until the bash tool is running.
- Press Stop / double Esc, or call
POST /session/{id}/abort. - Observe that the session remains busy and
sleep 30continues until its natural end. - Observe that the abort request returns only when the command finishes.
Screenshot and/or share link
The attached recording uses sleep 10 to keep the demo short; sleep 30 reproduces the same behavior.
https://github.com/user-attachments/assets/d248cac5-cadd-49f6-bfa0-74096878870c
Operating System
macOS
Terminal
OpenCode Web / headless server API
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.