[PR #13708] fix(config): make custom tool dependency install and loading resilient #14788

Open
opened 2026-02-16 18:19:32 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13708

State: open
Merged: No


Summary

Improve robustness of custom tool loading by handling transient dependency install failures and broken tool modules gracefully.

Problem

  1. Config.waitForDependencies() runs bun install once and silently swallows failures, which can fail transiently on Windows due to file locks.
  2. ToolRegistry.getCustom() directly imports each tool module; one broken custom tool can crash loading for all custom tools.

Solution

  • Add bounded retry (2 attempts on Windows with short backoff) for config dependency installs
  • Add try/catch around per-tool dynamic imports and continue loading remaining tools

Changes

  • packages/opencode/src/config/config.ts
    • Retry bun install on Windows before giving up
    • Log retry/final failure context
  • packages/opencode/src/tool/registry.ts
    • Guard dynamic imports with try/catch
    • Log failing module path and continue

Testing

  • Type check passes
  • Unit tests pass

AI-Assisted

Yes

Fixes #13784

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13708 **State:** open **Merged:** No --- ## Summary Improve robustness of custom tool loading by handling transient dependency install failures and broken tool modules gracefully. ## Problem 1. `Config.waitForDependencies()` runs `bun install` once and silently swallows failures, which can fail transiently on Windows due to file locks. 2. `ToolRegistry.getCustom()` directly imports each tool module; one broken custom tool can crash loading for all custom tools. ## Solution - Add bounded retry (2 attempts on Windows with short backoff) for config dependency installs - Add try/catch around per-tool dynamic imports and continue loading remaining tools ## Changes - `packages/opencode/src/config/config.ts` - Retry `bun install` on Windows before giving up - Log retry/final failure context - `packages/opencode/src/tool/registry.ts` - Guard dynamic imports with try/catch - Log failing module path and continue ## Testing - [x] Type check passes - [x] Unit tests pass ## AI-Assisted Yes Fixes #13784
yindo added the pull-request label 2026-02-16 18:19:32 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14788