Skip to content

core: interrupted tools cannot retain partial results #39565

Description

@rekram1-node

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions