fix: preserve Bedrock Converse API tool arguments in _parse_native_tool_call#4985
Open
guoyangzhen wants to merge 1 commit intocrewAIInc:mainfrom
Open
fix: preserve Bedrock Converse API tool arguments in _parse_native_tool_call#4985guoyangzhen wants to merge 1 commit intocrewAIInc:mainfrom
guoyangzhen wants to merge 1 commit intocrewAIInc:mainfrom
Conversation
…ol_call
Bedrock returns tool calls as {name, input, toolUseId} dicts without a
'function' key. The previous code used:
func_info.get('arguments', '{}') or tool_call.get('input', {})
When func_info is empty (no 'function' key), .get('arguments', '{}')
returns the default string '{}', which is truthy, causing the or to
short-circuit. The actual tool arguments in tool_call['input'] are
never used, resulting in all Bedrock tool calls receiving an empty dict.
Fix: remove the default value so .get('arguments') returns None when
the key is absent, allowing the or to fall through to 'input'.
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.
Fix
Fixes #4972
Problem
When using AWS Bedrock (Converse API) with native function calling, all tool arguments are silently dropped — every tool call receives an empty dict
{}instead of actual arguments.Root Cause
In
_parse_native_tool_call, the dict-handling branch has:Bedrock returns tool calls as
{"name": "...", "input": {...}, "toolUseId": "..."}— no"function"key. Sofunc_infois{}, andfunc_info.get("arguments", "{}")returns the default string"{}". Since"{}"is truthy, theorshort-circuits andtool_call["input"]is never evaluated.Fix
Remove the default value from
.get("arguments")so it returnsNonewhen the key is absent, allowing theorto fall through totool_call.get("input"):Behavior by provider:
tool_callstructure{"function": {"arguments": "{...}"}}"{...}"✅"{...}"✅{"input": {...}}(has attr){"name": "..", "input": {...}}"{}"❌{...}✅Testing
The fix can be verified by running a crew with Bedrock and a tool that has required arguments. Before the fix, all tool calls fail with
Field required [type=missing, input_value={}, input_type=dict]. After fix, arguments are correctly passed through.