anomalyco / anomalyco/opencode

core: interrupted tools cannot retain partial results

Open
#39,565 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

V2 tool execution uses Effect interruption, which prevents interrupted tools from attaching partial output to their terminal result. This causes useful diagnostics, such as Shell output produced before cancellation, to be lost.

Environment

  • opencode version: V2 development branch
  • OS: All
  • Terminal: Not applicable
  • Shell: Not applicable
  • Install/channel: V2 development
  • Active plugins: Not applicable

Reproduction

  1. Run a Shell tool command that periodically prints output.
  2. Interrupt the session while the command is still running.
  3. Inspect the interrupted tool result.

Expected Behavior

The tool should remain interrupted while retaining partial output or other useful result data produced before interruption.

For example, a Shell command interrupted after ten seconds should retain the output generated during those ten seconds.

Actual Behavior

Effect interruption prevents the tool executor from returning a normal result. The Shell interruption handler removes the Shell record and output file, so the partial output is unavailable.

Unlike V1, the leaf tool cannot convert cancellation into a successful result because V2 requires interruption to propagate.

Additional Context

This is broader than the Shell tool. Any V2 tool performing incremental work may need to attach partial results or diagnostics to an interrupted terminal outcome.

The likely solution belongs at the Job or tool-execution boundary:

  1. Preserve interruption semantics.
  2. Allow interruption cleanup to attach partial output or metadata.
  3. Record that information on the cancelled tool outcome.
  4. Avoid requiring leaf tools to swallow interruption and return success.

Shell is the immediate example, but the abstraction should support interrupted tools generally.

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.

Research direction

Start at the V2 Job or tool-execution boundary and trace how Effect interruption reaches the Shell interruption handler. Reproduce an interrupted command with periodic output, then define how partial output or diagnostics can be attached while preserving the interrupted terminal outcome for Shell and other incremental tools.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.