Skip to content

[BUG] V1 tool errors silently swallowed by Effect.orDie - AI never sees error messages #31772

Closed

Description

Description

V1 tools (edit, write, apply_patch, shell, glob, grep, etc.) that throw errors during execution have those errors silently swallowed. The root cause is Effect.orDie in packages/opencode/src/tool/tool.ts:146 which converts all errors to defects. Defects bypass the normal error reporting path and are invisible to the AI model.

Impact

The AI never sees error messages from V1 tools. Instead of receiving a clear error like "File not found" or "Permission denied", the tool silently returns nothing or the session appears to hang. This causes the AI to retry failed operations without understanding why they failed.

Root Cause

// tool.ts:146 - V1 tool wrapper
}).pipe(Effect.orDie, Effect.withSpan(...))

Effect.orDie converts ALL errors to defects (unrecoverable crashes). The core registry (packages/core/src/tool/registry.ts:68) only catches LLM.ToolFailure errors, not defects. So V1 tool runtime errors propagate as defects and never reach the model as meaningful error messages.

Affected Tools

All V1 tools defined via Tool.define() in packages/opencode/src/tool/:

  • edit.ts (throws on file not found, oldString mismatch)
  • write.ts (throws on write failures)
  • shell.ts (throws on spawn failures)
  • apply_patch.ts (throws on patch failures)
  • task.ts (throws on timeout/subagent failures)
  • glob.ts, grep.ts (throws on search failures)

OpenCode version

1.17.3

Activity

  1. github-actions commented on Jun 10, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    These may be related root causes or overlap with the behavior described here.

  2. hmannekomimi-ctrl2 commented on Jun 10, 2026

    @hmannekomimi-ctrl2

    Confirmed that this affects task.ts (subtask tool) specifically with a secondary effect: orphaned subagent sessions that continue running after the error, causing double processing when the orchestrator retries. Filed as #31787 with detailed root cause chain (Effect.orDie → acquireUseRelease skips cleanup → orphaned session).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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