Skip to content

Conversation

@roaminro
Copy link

@roaminro roaminro commented Feb 9, 2026

Summary

  • When toolChoice is 'none', send tool_choice: { type: "none" } with the tools array preserved instead of stripping both tools and tool_choice from the API request
  • Add { type: 'none' } to the AnthropicToolChoice type union
  • Update test to expect tools and toolChoice to be preserved

Problem

When toolChoice is 'none', the provider strips both tools and tool_choice from the request:

case 'none':
  // Anthropic does not support 'none' tool choice, so we remove the tools:
  return { tools: undefined, toolChoice: undefined, toolWarnings, betas };

This causes the Anthropic API to return content: [] (empty response) when the conversation history contains tool_use/tool_result blocks, because it sees tool blocks in history but no tools parameter.

This is a common issue in agentic loops where the last step needs to force a text-only response — the model produces zero text instead of a summary.

Anthropic API support

The comment "Anthropic does not support 'none' tool choice" is outdated. The Anthropic API officially supports tool_choice: { type: "none" } — it's listed in the tool use pricing table for every model from Claude 3 through Claude Opus 4.6:

Model Tool choice Token count
Claude Opus 4.6 auto, none 346 tokens

The docs also note: "If no tools are provided, then a tool choice of none uses 0 additional system prompt tokens."

Fixes #12378

Test plan

  • Updated existing should handle tool choice "none" test to verify tools and toolChoice are preserved
  • All 42 existing prepareTools tests pass

When toolChoice is 'none', the provider was stripping both tools and
tool_choice from the API request. This causes the Anthropic API to return
empty content when the conversation history contains tool_use/tool_result
blocks, because it sees tool blocks without a tools parameter.

Instead, send tool_choice: { type: "none" } with the tools array preserved.
The Anthropic API supports tool_choice "none" since the 2025-04-15 version.

Fixes vercel#12378
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

anthropic provider: toolChoice 'none' strips tools from request, causing empty response with tool_use history

1 participant