[PR #9833] feat(tool): add new PTC tools for client-side Programmatic Tool Calling #13235

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

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

State: open
Merged: No


What does this PR do?

Implements client-side PTC, allowing models to execute JavaScript code that orchestrates multiple tool calls in a single execution context.

Why:

  • Claude Code implements this server-side (see [1])
  • OpenCode's client-side approach offers: context savings (no round-trips), model-agnostic (works with any provider)

Without PTC:

  • Each tool call requires a full model round-trip
  • Context grows linearly with tool calls
  • Complex multi-step operations are verbose and slow

Tools added:

  • ptc: Execute async JS with access to all tools via tools.*
  • ptc_list: List available tools with TypeScript signatures

Features:

  • Independent UI tracking per sub-tool call
  • Permission enforcement inherited from parent context
  • 5-minute timeout protection

Enable: OPENCODE_EXPERIMENTAL_PTC=true

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

How did you verify your code works?

  • verified by hand and the tools works normally

[1] https://platform.claude.com/docs/en/agents-and-tools/tool-use/programmatic-tool-calling

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/9833 **State:** open **Merged:** No --- ### What does this PR do? Implements client-side PTC, allowing models to execute JavaScript code that orchestrates multiple tool calls in a single execution context. Why: - Claude Code implements this server-side (see [1]) - OpenCode's client-side approach offers: context savings (no round-trips), model-agnostic (works with any provider) Without PTC: - Each tool call requires a full model round-trip - Context grows linearly with tool calls - Complex multi-step operations are verbose and slow Tools added: - `ptc`: Execute async JS with access to all tools via `tools.*` - `ptc_list`: List available tools with TypeScript signatures Features: - Independent UI tracking per sub-tool call - Permission enforcement inherited from parent context - 5-minute timeout protection Enable: OPENCODE_EXPERIMENTAL_PTC=true Closes https://github.com/anomalyco/opencode/issues/4713 ### How did you verify your code works? - verified by hand and the tools works normally --- [1] https://platform.claude.com/docs/en/agents-and-tools/tool-use/programmatic-tool-calling
yindo added the pull-request label 2026-02-16 18:18:06 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13235