feat(plugin): add providers field to scope tool overrides by provider#15125
Open
broskees wants to merge 2 commits intoanomalyco:devfrom
Open
feat(plugin): add providers field to scope tool overrides by provider#15125broskees wants to merge 2 commits intoanomalyco:devfrom
broskees wants to merge 2 commits intoanomalyco:devfrom
Conversation
Add optional `providers` field to ToolDefinition that lets plugins scope tool overrides to specific providers. When set, the tool is only included in the tool list when the active provider matches. When excluded, any built-in tool with the same ID is preserved via deduplication. This enables plugins that override built-in tools (bash, read, edit, etc.) to do so only for their target provider without losing built-in functionality for other providers.
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
No existing issue — this came up building a plugin that overrides
bash/read/editfor a custom provider but breaks those tools for every other provider.Type of change
What does this PR do?
Plugin tool overrides are global today. If a plugin registers
bash, the built-inBashToolis replaced for all providers — no way to scope it.This adds
providers?: string[]toToolDefinitionandTool.Info. When set, the tool is only included for matching providers. Thetools()function filters by provider then deduplicates by id (last wins), so when a plugin override is excluded the built-in with the same id survives.Three files changed:
packages/plugin/src/tool.ts— addprovidersto input typepackages/opencode/src/tool/tool.ts— addproviderstoTool.Infopackages/opencode/src/tool/registry.ts— pass through infromPlugin, filter + dedup intools()How did you verify your code works?
Read the existing
tools()flow and traced thatall()returns[...builtins, ...custom]. With the filter + Map dedup, confirmed:providers: ["my-provider"]→ override active only formy-provider, built-in used for othersproviders→ current behavior unchanged (override is global)Screenshots / recordings
N/A — no UI changes.
Checklist