[PR #7390] [FEATURE] Add Anthropic Advanced Tool Use beta support #12381

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

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

State: open
Merged: No


Summary

Adds support for Anthropic's Advanced Tool Use beta features via feature flag.

Closes #4713


Motivation

OpenCode currently loads all MCP tool definitions upfront. For power users with multiple MCP servers, this creates high token costs (50K-100K+ tokens before any work begins).

Anthropic released beta features specifically designed to address this:

  • 85% token reduction with Tool Search Tool
  • 37% token reduction with Programmatic Tool Calling
  • Significant accuracy improvements with Tool Use Examples

This PR adds the foundation for these capabilities.


Changes

Beta Header Support

Added OPENCODE_ADVANCED_TOOL_USE feature flag that enables the advanced-tool-use-2025-11-20 beta:

// packages/opencode/src/provider/provider.ts
const advancedToolUseEnabled = Env.all()["OPENCODE_ADVANCED_TOOL_USE"] === "true"

const betaFeatures = [
  "claude-code-20250219",
  "interleaved-thinking-2025-05-14",
  "fine-grained-tool-streaming-2025-05-14",
]

if (advancedToolUseEnabled) {
  betaFeatures.push("advanced-tool-use-2025-11-20")
}

Usage

export OPENCODE_ADVANCED_TOOL_USE=true
opencode

Breaking Changes

None. Feature flag defaults to false. Without the flag, OpenCode behaves exactly as before.


Testing

  • Typecheck passes
  • No breaking changes introduced
  • Feature flag defaults to off (safe to merge)

Next Steps

This PR lays the foundation for:

  1. Tool Search Tool - defer_loading config for MCP tools
  2. Programmatic Tool Calling - Code execution sandbox
  3. Tool Use Examples - input_examples in tool schemas

I can implement these in follow-up PRs if this approach is approved.


References


Author Notes

I'm a power user running OpenCode with 9+ MCP servers. This feature would save me 50K-70K tokens per session. Happy to implement the full feature set if this foundation is accepted.

Thanks for reviewing! 🚀

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7390 **State:** open **Merged:** No --- ## Summary Adds support for Anthropic's Advanced Tool Use beta features via feature flag. **Closes #4713** --- ## Motivation OpenCode currently loads all MCP tool definitions upfront. For power users with multiple MCP servers, this creates high token costs (50K-100K+ tokens before any work begins). Anthropic released beta features specifically designed to address this: - **85% token reduction** with Tool Search Tool - **37% token reduction** with Programmatic Tool Calling - **Significant accuracy improvements** with Tool Use Examples This PR adds the foundation for these capabilities. --- ## Changes ### Beta Header Support Added `OPENCODE_ADVANCED_TOOL_USE` feature flag that enables the `advanced-tool-use-2025-11-20` beta: ```typescript // packages/opencode/src/provider/provider.ts const advancedToolUseEnabled = Env.all()["OPENCODE_ADVANCED_TOOL_USE"] === "true" const betaFeatures = [ "claude-code-20250219", "interleaved-thinking-2025-05-14", "fine-grained-tool-streaming-2025-05-14", ] if (advancedToolUseEnabled) { betaFeatures.push("advanced-tool-use-2025-11-20") } ``` ### Usage ```bash export OPENCODE_ADVANCED_TOOL_USE=true opencode ``` --- ## Breaking Changes **None.** Feature flag defaults to `false`. Without the flag, OpenCode behaves exactly as before. --- ## Testing - ✅ Typecheck passes - ✅ No breaking changes introduced - ✅ Feature flag defaults to off (safe to merge) --- ## Next Steps This PR lays the foundation for: 1. **Tool Search Tool** - `defer_loading` config for MCP tools 2. **Programmatic Tool Calling** - Code execution sandbox 3. **Tool Use Examples** - `input_examples` in tool schemas I can implement these in follow-up PRs if this approach is approved. --- ## References - **Anthropic docs:** https://www.anthropic.com/engineering/advanced-tool-use - **Issue #4713:** Feature request with community support - **Related:** claude-code issue #12836 (100+ upvotes) --- ## Author Notes I'm a power user running OpenCode with 9+ MCP servers. This feature would save me 50K-70K tokens per session. Happy to implement the full feature set if this foundation is accepted. Thanks for reviewing! 🚀
yindo added the pull-request label 2026-02-16 18:17:17 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12381