Skip to content

Conversation

@yuguorui
Copy link
Contributor

What does this PR do?

Programmatic Tool Calling (PTC)[1] lets code invoke tools directly in the execution environment, cutting model round-trips, latency, and tokens. Without an execution API, models could not programmatically invoke tools and had to fall back to provider-native tool calling, which blocks PTC on other models.

Introduce a tool execution API to run a tool by id with session/message context, provider/agent filtering, and permission gating, returning title/output/metadata.

Regenerate the JS SDK (v1/v2) to expose the new execute API and types so plugins can implement PTC regardless of the underlying model provider.

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

Closes #4713

How did you verify your code works?

I've writing a POC plugin to wrap the tools into async javascript functions, and the model is able to create 10k TODOs 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.

image

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on the search results, I found one potentially related PR:

Related PR:

This PR appears related because it also deals with advanced tool use functionality. While PR #8022 introduces a general-purpose tool execution API for Programmatic Tool Calling (PTC) that works across providers, PR #7390 specifically addresses Anthropic's Advanced Tool Use beta support. They may be complementary features or address similar tool invocation patterns.

@yuguorui yuguorui changed the title feat: plugin: add plugin tool execution for PTC feat: plugin: add plugin tool execution for Programmatic Tool Calling (PTC) Jan 12, 2026
@yuguorui
Copy link
Contributor Author

The typecheck-related failures are unrelated to this change, and the issue was first reported in #7532 .

@yuguorui yuguorui changed the title feat: plugin: add plugin tool execution for Programmatic Tool Calling (PTC) feat: plugin: add plugin interfaces for Programmatic Tool Calling (PTC) Jan 12, 2026
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.

Signed-off-by: yuguorui <[email protected]>
---
[1] https://platform.claude.com/cookbook/tool-use-programmatic-tool-calling-ptc
@yuguorui yuguorui force-pushed the feat/programmatic-tool-calling branch from c14fd4d to b8f5595 Compare January 13, 2026 09:43
@yuguorui yuguorui closed this Jan 13, 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.

[FEATURE]: Claude Advanced Tool Usage

1 participant