anomalyco / anomalyco/opencode

Session abort waits for a model-invoked bash tool to finish

Open
#40,829 2 comments 0 reactions 1 assignee View on GitHub

@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
  1. Start opencode serve or opencode web.
  2. Ask the model: "Only call bash and run sleep 30 in the foreground. Wait for it to finish before replying."
  3. Wait until the bash tool is running.
  4. Press Stop / double Esc, or call POST /session/{id}/abort.
  5. Observe that the session remains busy and sleep 30 continues until its natural end.
  6. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.