Skip to content

feat(plugin): add providers field to scope tool overrides by provider#15125

Open
broskees wants to merge 2 commits intoanomalyco:devfrom
broskees:feat/plugin-tool-providers-filter
Open

feat(plugin): add providers field to scope tool overrides by provider#15125
broskees wants to merge 2 commits intoanomalyco:devfrom
broskees:feat/plugin-tool-providers-filter

Conversation

@broskees
Copy link

@broskees broskees commented Feb 25, 2026

Issue for this PR

No existing issue — this came up building a plugin that overrides bash/read/edit for a custom provider but breaks those tools for every other provider.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Plugin tool overrides are global today. If a plugin registers bash, the built-in BashTool is replaced for all providers — no way to scope it.

This adds providers?: string[] to ToolDefinition and Tool.Info. When set, the tool is only included for matching providers. The tools() 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 — add providers to input type
  • packages/opencode/src/tool/tool.ts — add providers to Tool.Info
  • packages/opencode/src/tool/registry.ts — pass through in fromPlugin, filter + dedup in tools()

How did you verify your code works?

Read the existing tools() flow and traced that all() returns [...builtins, ...custom]. With the filter + Map dedup, confirmed:

  • Plugin with providers: ["my-provider"] → override active only for my-provider, built-in used for others
  • Plugin without providers → current behavior unchanged (override is global)

Screenshots / recordings

N/A — no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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.
@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Feb 25, 2026
@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Feb 25, 2026
@github-actions
Copy link
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@broskees broskees changed the title feat: add providers field to scope plugin tools by provider feat(plugin): add providers field to scope tool overrides by provider Feb 25, 2026
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.

1 participant