Repository navigation
Conversation
…edrock and Anthropic
Claude Opus 5.5 rejects a forced tool_choice ("any" or a named tool) with
`tool_choice: type "tool" and "any" are not supported for this model.`
The default structured_output_strategy="tool" forces "any" in both
AmazonBedrockPromptDriver and AnthropicPromptDriver, so every Agent with an
output_schema fails on Opus 5.5.
Add supports_forced_tool_choice() next to supports_sampling_params(),
backed by a FORCED_TOOL_CHOICE_UNSUPPORTED_MIN_VERSIONS table ({"opus":
(5, 5)}) and the same version parsing (extracted into _is_at_or_above()).
Both drivers skip the "any" override when it returns False, so the
configured tool_choice (default auto) is sent. Opus 5 and earlier, other
Claude families, and non-Claude models are unchanged.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
collindutter
self-requested a review
September 23, 2026 20:18
Claude Sonnet 5.5 (anthropic.claude-sonnet-5-5, on Bedrock since 2026-09-28) rejects a forced tool_choice with the same `tool_choice: type "tool" and "any" are not supported for this model.` as Opus 5.5. Add "sonnet": (5, 5) to FORCED_TOOL_CHOICE_UNSUPPORTED_MIN_VERSIONS. Sonnet 5 still accepts the forced "any" and keeps it. Co-Authored-By: Claude <noreply@anthropic.com>
1 task done
Member
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.
Thanks for the version-keyed gate in
anthropic_utilsfrom #2251 and #2261; it made this a small change.Describe your changes
Claude Opus 5.5 and Sonnet 5.5 reject a forced
tool_choice(anyor a named tool), which the defaultstructured_output_strategy="tool"sends. This addssupports_forced_tool_choice()next tosupports_sampling_params(), backed by aFORCED_TOOL_CHOICE_UNSUPPORTED_MIN_VERSIONStable ({"opus": (5, 5), "sonnet": (5, 5)}). Both use the same version parsing, now in a shared_is_at_or_above(). Both drivers skip theanyoverride when it returns False, so the configuredtool_choice(defaultauto) is sent. Sonnet 5.5 reached Bedrock on 2026-09-28 with the same 400, soc2dfddbadds its row.AmazonBedrockPromptDriver+output_schema,us./global.anthropic.claude-opus-5-5, stream on/offValidationException{'answer': 'OK'}AmazonBedrockPromptDriver+output_schema,us./global.anthropic.claude-sonnet-5-5, stream on/offValidationException{'answer': 'OK'}AnthropicPromptDriver(AnthropicBedrockclient) +output_schema, Opus 5.5 and Sonnet 5.5{'answer': 'OK'}anystill sentai21.j2),rulestrategysupports_sampling_params()resultsRED: source files reset to main, new tests kept
12 of the 16 failures are the helper tests; the 4 driver cases still send
any.Sonnet 5.5 rows (
c2dfddb),anthropic_utils.pyreset to98f3e64, new rows kept:Live,
Agent(output_schema=Schema({"answer": str})).run("Reply with answer=OK"), before (main):After (this branch):
Sonnet 5.5, before (
98f3e64) and after (c2dfddb):With
autothe model could answer without calling the tool. Opus 5.5 and Sonnet 5.5 each called it for all 5 prompts I tried, so I left that alone here.Issue ticket number and link
Fixes #2351
References: announcement · migration guide