[PR #8180] feat(plugin): add programmatic tool invocation support (PTC) #12653

Closed
opened 2026-02-16 18:17:33 -05:00 by yindo · 0 comments
Owner

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

State: closed
Merged: No


What does this PR do?

Introduce Programmatic Tool Calling (PTC) support for plugins, enabling plugins to invoke tools directly within a session without relying on LLM vendor-specific APIs.

This change exposes a unified tool invocation API that:

  • Allows plugins to execute tools programmatically
  • Reduces LLM round-trips and token consumption
  • Decouples plugin PTC implementation from underlying model providers (e.g. Anthropic-specific APIs)

To support this, the JS SDK (v1/v2) is regenerated to expose the new execute API and related types, allowing plugin authors to implement PTC in a provider-agnostic way.

Without this change, plugins in opencode can only achieve PTC via vendor-dependent LLM APIs and cannot invoke tools directly.


[1] https://platform.claude.com/cookbook/tool-use-programmatic-tool-calling-ptc

Closes https://github.com/anomalyco/opencode/issues/4713

How did you verify your code works?

I've written a POC plugin to wrap the tools into async javascript functions, and the model is able to create 10k TODOs or 10 subtasks concurrently with the new interface.

Because it currently depends on a local SDK version, it has not been released yet. I will complete it as soon as possible and open-source it under the MIT license.

534655848-49e67f16-bcfb-48a0-813b-37eaa09e9795
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8180 **State:** closed **Merged:** No --- ### What does this PR do? Introduce Programmatic Tool Calling (PTC) support for plugins, enabling plugins to invoke tools directly within a session without relying on LLM vendor-specific APIs. This change exposes a unified tool invocation API that: - Allows plugins to execute tools programmatically - Reduces LLM round-trips and token consumption - Decouples plugin PTC implementation from underlying model providers (e.g. Anthropic-specific APIs) To support this, the JS SDK (v1/v2) is regenerated to expose the new `execute` API and related types, allowing plugin authors to implement PTC in a provider-agnostic way. Without this change, plugins in opencode can only achieve PTC via vendor-dependent LLM APIs and cannot invoke tools directly. --- [1] https://platform.claude.com/cookbook/tool-use-programmatic-tool-calling-ptc Closes https://github.com/anomalyco/opencode/issues/4713 ### How did you verify your code works? I've written a POC plugin to wrap the tools into async javascript functions, and the model is able to create 10k TODOs or 10 subtasks concurrently with the new interface. Because it currently depends on a local SDK version, it has not been released yet. I will complete it as soon as possible and open-source it under the MIT license. <img width="3170" height="1742" alt="534655848-49e67f16-bcfb-48a0-813b-37eaa09e9795" src="https://github.com/user-attachments/assets/41b0f6cb-eed5-4f28-88b4-e9ffcdaa5d14" />
yindo added the pull-request label 2026-02-16 18:17:33 -05:00
yindo closed this issue 2026-02-16 18:17:33 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12653