anomalyco / anomalyco/opencode
core: interrupted tools cannot retain partial results
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
- Run a Shell tool command that periodically prints output.
- Interrupt the session while the command is still running.
- 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:
- Preserve interruption semantics.
- Allow interruption cleanup to attach partial output or metadata.
- Record that information on the cancelled tool outcome.
- 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
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.
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