Skip to content

fix(tool): register lsp tool when LSP is configured, not behind experimental flag - #2049

Open
YOMXXX wants to merge 2 commits into
XiaomiMiMo:mainfrom
YOMXXX:fix/lsp-tool-registration
Open

fix(tool): register lsp tool when LSP is configured, not behind experimental flag#2049
YOMXXX wants to merge 2 commits into
XiaomiMiMo:mainfrom
YOMXXX:fix/lsp-tool-registration

Conversation

@YOMXXX

@YOMXXX YOMXXX commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #2017. The lsp tool never appears in the agent tool list even when LSP servers are configured (e.g. lsp.rust-analyzer).

Root cause: packages/opencode/src/tool/registry.ts gated the lsp tool behind Flag.MIMOCODE_EXPERIMENTAL_LSP_TOOL, which defaults OFF. The tool was therefore never registered for normal users regardless of LSP configuration or server-launch timing.

Fix: register the lsp tool when LSP is configured — lspEnabled = Boolean(cfg.lsp) || Flag.MIMOCODE_EXPERIMENTAL_LSP_TOOL:

  • config.lsp truthy (true or a server record) → lsp tool registered.
  • config.lsp falsy (default) → not registered (no token overhead for non-LSP users).
  • The experimental flag is retained as a force-enable override (backward compatible).

The lsp tool itself already handles "no server for this file type" at runtime via lsp.hasClients, so no change to the tool's execute path.

Test Plan

  • New tests: registry.ids() contains lsp with config: { lsp: true }; does NOT contain lsp with config: { lsp: false }.
  • bun test test/tool/registry.test.ts — 7 pass.
  • bun typecheck — clean.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Agent 工具列表永不注册 lsp 工具:LSP server 懒加载时序晚于会话创建时的 resolveTools

1 participant