[PR #12050] feat(plugin): align plugin tool types with built-in tool capabilities #14046

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

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

State: open
Merged: No


What does this PR do?

Fixes: #8327

Related: #8269, #12042

Important

I'd be happy to close out this PR in favor of #6544 as I said in my comment here. I think the tests in this PR would be good to pull over though, but the code is essentially the same.

This PR aligns plugin tool types with the capabilities tools already have. Specifically:

  • Exposes ToolContext fields to plugin tools: callID, extra, metadata(), and ask() to give plugins the correct context types
  • Adds ExecuteResult type allowing plugin tools to return structured result objects with title, metadata, output, and attachments instead of only plain strings
  • Updates the registry to handle structured results from plugin tools, bypassing truncation when plugins return an ExecuteResult directly (assuming tools till truncate...we could add a check here?)
  • Exports all useful intermediate-types so plugin authors can use them more ergonomically.

This enables plugins to provide richer tool responses with proper metadata updates, closer matching the flexibility of built-in tools.

How did you verify your code works?

  • Added tests to ensure both string returns and object returns work as expected
  • Ran TypeScript type checking
  • Verified locally with a plugin in development that required proper metadata updates from plugin tools

The types all align nicely in the registry:

type changes

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12050 **State:** open **Merged:** No --- ### What does this PR do? Fixes: #8327 Related: #8269, #12042 > [!IMPORTANT] > I'd be happy to close out this PR in favor of #6544 as I said in my [comment here](https://github.com/anomalyco/opencode/pull/6544#issuecomment-3773220521). I think the tests in this PR would be good to pull over though, but the code is essentially the same. This PR aligns plugin tool types with the capabilities tools already have. Specifically: - Exposes `ToolContext` fields to plugin tools: `callID`, `extra`, ~`metadata()`~, and ~`ask()`~ to give plugins the correct context types - update: `metadata()` and `ask()` were added in #8269 - Adds `ExecuteResult` type allowing plugin tools to return structured result objects with `title`, `metadata`, `output`, and `attachments` instead of only plain strings - Updates the registry to handle structured results from plugin tools, bypassing truncation when plugins return an `ExecuteResult` directly (assuming tools till truncate...we could add a check here?) - Exports all useful intermediate-types so plugin authors can use them more ergonomically. This enables plugins to provide richer tool responses with proper metadata updates, closer matching the flexibility of built-in tools. ### How did you verify your code works? - Added tests to ensure both string returns and object returns work as expected - Ran TypeScript type checking - Verified locally with a plugin in development that required proper metadata updates from plugin tools The types all align nicely in the registry: ![type changes](https://github.com/user-attachments/assets/9b2244ac-9476-4b28-ae85-ae27fbbc7e12)
yindo added the pull-request label 2026-02-16 18:18:51 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14046