Repository navigation
fix(anthropic): fall back to auto tool_choice for Opus 5.5, Sonnet 5.5, Fable 5.1 and Mythos 5.1 - #2753
Merged
Conversation
🦋 Changeset detectedLatest commit: 10d0f8b The changes in this PR will be included in the next version bump. This PR includes changesets to release 41 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
davidzhao
approved these changes
Oct 17, 2026
This was referenced Oct 17, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Port livekit/agents#7511 to fall back from forced Anthropic tool choices to
autofor Claude Opus 5.5, Sonnet 5.5, Fable 5.1, and Mythos 5.1. Preservedisable_parallel_tool_usewhen configured and warn once perLLMinstance.Source diff coverage
Source diff coverage
livekit-plugins/livekit-plugins-anthropic/livekit/plugins/anthropic/llm.py->plugins/anthropic/src/llm.ts. Ported all unsupported-model prefixes, the per-instance warning guard, forcedany/named-tool fallback toauto, preservation ofdisable_parallel_tool_use, and model logging metadata using the target Pino API.tests/test_plugin_anthropic_request.py->plugins/anthropic/src/llm.test.ts. Ported both request-level tests into the existing Vitest counterpart with a mocked Anthropic client. Test fixtures explicitly unset the JS-specific defaultparallelToolCalls: truewhere the Python source tests exercise the omitted-option case; the explicitfalsecase remains covered.Authoritative source: livekit/agents#7511
Validation
pnpm test plugins/anthropic(17 passed)pnpm --filter @livekit/agents-plugin-anthropic buildpnpm --filter @livekit/agents-plugin-anthropic lintpnpm exec prettier --check plugins/anthropic/src/llm.ts plugins/anthropic/src/llm.test.ts .changeset/anthropic-auto-tool-choice.mdpnpm build(42 workspace tasks passed)pnpm lint(fails on 307 pre-existing findings in unrelated files; the Anthropic package lint passes)Ported from livekit/agents#7511
Original PR description
Problem
LLM.chat()translates a forcedtool_choicethe same way for every model:"required"becomes{"type": "any"}and a named function becomes{"type": "tool", "name": ...}. Claude Opus 5.5, Sonnet 5.5, Fable 5.1 and Mythos 5.1 don't support forced tool use (Opus 5.5, Sonnet 5.5, Fable 5.1 and Mythos 5.1 migration guides), so on these models every such request fails with a 400:tool_choice: type "tool" and "any" are not supported for this model.AMD and keyterm detection force"required"on their own, so they fail on these models even when the app never sets a tool choice.Changes
For these four models a forced choice is now sent as
{"type": "auto"}, keepingdisable_parallel_tool_usewhen it's set, and the plugin logs a warning once perLLMinstance. Requests for all other models are unchanged. These models have no forced mode, so the model may now answer without calling a tool, or call a different tool than the one named.