fix(aws): keep toolConfig when tool_choice="none" to prevent ValidationException#5595
Open
weiguangli-io wants to merge 1 commit intolivekit:mainfrom
Open
fix(aws): keep toolConfig when tool_choice="none" to prevent ValidationException#5595weiguangli-io wants to merge 1 commit intolivekit:mainfrom
weiguangli-io wants to merge 1 commit intolivekit:mainfrom
Conversation
…onException When tool_choice="none" is passed (e.g. during agent handoff draining), _get_tool_config() was returning None, causing toolConfig to be omitted from the Bedrock ConverseStream request. AWS raises ValidationException when toolUse/toolResult content blocks are present but toolConfig is absent. Fix by removing the else-return-None branch so that tool_choice="none" falls through without setting toolChoice, keeping the toolConfig with the tools list intact. Fixes livekit#5589 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
Fixes #5589.
When
tool_choice="none"is passed to the AWS Bedrock LLM plugin (e.g. during agent handoff whendraining=True),_get_tool_config()was hitting theelse: return Nonebranch, causingtoolConfigto be omitted entirely from theConverseStreamrequest. AWS raisesValidationExceptionwhentoolUse/toolResultcontent blocks exist in the message history buttoolConfigis absent.Root cause: The
else: return Nonebranch handled any unrecognizedtool_choicevalue by removing tool config entirely. The string"none"is a validToolChoicevalue meaning "don't force tool use", but AWS has no equivalenttoolChoicefield value — the correct behavior is to includetoolConfig(with the tools list) but omit thetoolChoiceconstraint, which lets Bedrock default to its auto behavior.Fix: Remove the
else: return Nonebranch sotool_choice="none"falls through without settingtoolConfig["toolChoice"], keeping the tools config intact.Changes
livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/llm.py: removedelse: return Nonein_get_tool_config(), replaced with a comment explaining the intent fortool_choice="none"Test plan
ValidationExceptionsession.generate_reply(tool_choice=None)when the chat context contains tool call/result messages — should succeedtool_choice="auto",tool_choice="required", and named tool choice still work correctlyNonefrom_get_tool_config()correctly🤖 Generated with Claude Code