Skip to content

fix(anthropic): ToolChoiceNone should send tool_choice:{type:"none"} to API - #178

Merged
andreynering merged 1 commit into
mainfrom
fix-anthropic-tool-choice-none-177
Mar 18, 2026
Merged

andreynering merged 1 commit into
mainfrom
fix-anthropic-tool-choice-none-177

Conversation

@andreynering

@andreynering andreynering commented Mar 18, 2026 •

Copy link
Copy Markdown
Member

The Anthropic provider's toTools function was returning nil for anthropicToolChoice when ToolChoiceNone was set, which meant tool_choice was never included in the API request. The API defaults to "auto", so the model could still make tool calls.

Now properly constructs ToolChoiceUnionParam with OfNone set using anthropic.NewToolChoiceNoneParam().

Also adds test coverage for ToolChoiceNone.

💘 Generated with Crush

Assisted-by: Kimi K2.5 via Crush crush@charm.land

…to API

The Anthropic provider's toTools function was returning nil for
anthropicToolChoice when ToolChoiceNone was set, which meant
tool_choice was never included in the API request. The API defaults
to "auto", so the model could still make tool calls.

Now properly constructs ToolChoiceUnionParam with OfNone set using
anthropic.NewToolChoiceNoneParam().

Also adds test coverage for ToolChoiceNone.

* Closes #177

💘 Generated with Crush

Assisted-by: Kimi K2.5 via Crush <crush@charm.land>
@andreynering andreynering self-assigned this Mar 18, 2026
@andreynering
andreynering merged commit d749d13 into main Mar 18, 2026
17 checks passed
@andreynering
andreynering deleted the fix-anthropic-tool-choice-none-177 branch March 18, 2026 18:02
taigrr pushed a commit to taigrr/fantasy that referenced this pull request Apr 20, 2026
…to API (charmbracelet#178)

The Anthropic provider's toTools function was returning nil for
anthropicToolChoice when ToolChoiceNone was set, which meant
tool_choice was never included in the API request. The API defaults
to "auto", so the model could still make tool calls.

Now properly constructs ToolChoiceUnionParam with OfNone set using
anthropic.NewToolChoiceNoneParam().

Also adds test coverage for ToolChoiceNone.

* Closes charmbracelet#177

💘 Generated with Crush

Assisted-by: Kimi K2.5 via Crush <crush@charm.land>
taigrr pushed a commit to taigrr/fantasy that referenced this pull request Apr 25, 2026
…to API (charmbracelet#178)

The Anthropic provider's toTools function was returning nil for
anthropicToolChoice when ToolChoiceNone was set, which meant
tool_choice was never included in the API request. The API defaults
to "auto", so the model could still make tool calls.

Now properly constructs ToolChoiceUnionParam with OfNone set using
anthropic.NewToolChoiceNoneParam().

Also adds test coverage for ToolChoiceNone.

* Closes charmbracelet#177

💘 Generated with Crush

Assisted-by: Kimi K2.5 via Crush <crush@charm.land>
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: ToolChoiceNone returns nil, tool_choice:{type:“none”} never sent to API

2 participants