Skip to content

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

Open
yuguorui wants to merge 3 commits intoanomalyco:devfrom
yuguorui:feat/tool-ptc
Open

feat(tool): add new PTC tools for client-side Programmatic Tool Calling#9833
yuguorui wants to merge 3 commits intoanomalyco:devfrom
yuguorui:feat/tool-ptc

Conversation

@yuguorui
Copy link
Copy Markdown
Contributor

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 #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

@github-actions
Copy link
Copy Markdown
Contributor

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

No duplicate PRs found

@yuguorui yuguorui changed the title feat(tool): add PTC (Programmatic Tool Calling) support feat(tool): add new PTC tools for client-side Programmatic Tool Calling Jan 21, 2026
@thdxr thdxr force-pushed the dev branch 3 times, most recently from f1ae801 to 08fa7f7 Compare January 30, 2026 14:37
@yuguorui yuguorui force-pushed the feat/tool-ptc branch 3 times, most recently from 5563891 to 4fab06b Compare February 25, 2026 09:29
@yuguorui yuguorui force-pushed the feat/tool-ptc branch 3 times, most recently from 0090e8b to c6bcb9b Compare March 30, 2026 15:17
yuguorui added 3 commits April 2, 2026 11:24
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

Signed-off-by: yuguorui <yuguorui@pku.edu.cn>
---
[1] https://platform.claude.com/docs/en/agents-and-tools/tool-use/programmatic-tool-calling
Signed-off-by: yuguorui <yuguorui@pku.edu.cn>
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