Skip to content

fix(config): make custom tool dependency install and loading resilient#13708

Open
sauerdaniel wants to merge 1 commit intoanomalyco:devfrom
sauerdaniel:pr/config-tool-resilience
Open

fix(config): make custom tool dependency install and loading resilient#13708
sauerdaniel wants to merge 1 commit intoanomalyco:devfrom
sauerdaniel:pr/config-tool-resilience

Conversation

@sauerdaniel
Copy link
Contributor

@sauerdaniel sauerdaniel commented Feb 15, 2026

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

@github-actions
Copy link
Contributor

Hey! Your PR title fix(config/tool): make custom tool dependency install and loading resilient doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

I found a potential duplicate PR:

This PR may be a related or overlapping fix. You should check if #12270 was already merged or if it's still open and addresses the same problem.

@sauerdaniel sauerdaniel changed the title fix(config/tool): make custom tool dependency install and loading resilient fix(opencode): make custom tool dependency install and loading resilient Feb 16, 2026
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@sauerdaniel
Copy link
Contributor Author

Re: potential duplicate with #12270 — there's partial overlap on registry.ts (both wrap import(match) in try/catch). This PR also fixes config.ts dependency installation (waitForDependencies error handling), which #12270 doesn't cover.

If #12270 merges first, I'll rebase to keep only the config.ts fix.

@sauerdaniel sauerdaniel force-pushed the pr/config-tool-resilience branch from 8c4ed40 to 886e49c Compare February 16, 2026 02:44
@sauerdaniel sauerdaniel force-pushed the pr/config-tool-resilience branch from 886e49c to 3425b6c Compare February 16, 2026 11:06
@sauerdaniel sauerdaniel changed the title fix(opencode): make custom tool dependency install and loading resilient fix(config): make custom tool dependency install and loading resilient Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom tool loading crashes on transient dependency install failures

1 participant

Comments