fix: Bedrock Converse API tool arguments silently dropped (#4972)#4978
Open
guoyangzhen wants to merge 1 commit intocrewAIInc:mainfrom
Open
fix: Bedrock Converse API tool arguments silently dropped (#4972)#4978guoyangzhen wants to merge 1 commit intocrewAIInc:mainfrom
guoyangzhen wants to merge 1 commit intocrewAIInc:mainfrom
Conversation
…4972) When using AWS Bedrock with native function calling, all tool arguments were silently dropped because of a truthy default in dict.get(). The bug: func_info.get('arguments', '{}') returns '{}' (truthy string) when the 'function' key is absent (Bedrock format), so the fallback or tool_call.get('input', {}) is never evaluated. The fix: remove the default so get() returns None (falsy), allowing the 'or' to correctly fall through to tool_call.get('input'). # Before (broken): func_args = func_info.get('arguments', '{}') or tool_call.get('input', {}) # After (fixed): func_args = func_info.get('arguments') or tool_call.get('input') or '{}' Bedrock Converse API returns: {name, input, toolUseId} (no 'function' key). OpenAI returns: {function: {name, arguments}} (has 'function' key). Both formats are now correctly handled. Fixes crewAIInc#4972
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.
Problem
When using AWS Bedrock with native function calling, all tool arguments are silently dropped. Every tool call receives an empty dict
{}instead of the actual arguments, causing pydantic validation failures on any tool with required parameters.This affects ALL Bedrock models using native function calling (Claude, Llama, etc.) via the native tool loop code path.
Root Cause
In
_parse_native_tool_call(crew_agent_executor.py), the dict-format branch has a truthy default:Bedrock Converse API returns
{name, input, toolUseId}— no"function"key.So
func_infois{}, andfunc_info.get("arguments", "{}")returns the default"{}"— a truthy string. Theorshort-circuits andtool_call.get("input", {})is never evaluated.Fix
Remove the default so
get()returnsNone(falsy), allowing theorto fall through:Verification
Tests Added
test_parse_native_tool_call_bedrock_format— verifies Bedrock input dict is correctly extractedtest_parse_native_tool_call_openai_dict_format— verifies OpenAI format still worksFixes #4972