fix: Bedrock tool call arguments no longer silently dropped (closes #5275)#5277
Open
TheCodingDragon0 wants to merge 1 commit intocrewAIInc:mainfrom
Open
fix: Bedrock tool call arguments no longer silently dropped (closes #5275)#5277TheCodingDragon0 wants to merge 1 commit intocrewAIInc:mainfrom
TheCodingDragon0 wants to merge 1 commit intocrewAIInc:mainfrom
Conversation
…rewAIInc#5275) When using AWS Bedrock LLMs, tool arguments were being discarded because the default value of '{}' in func_info.get('arguments', '{}') was truthy, preventing the fallback to tool_call.get('input', {}). Changed default from '{}' to None so the or-chain correctly falls through to the Bedrock input format when no 'function' wrapper is present.
|
A small regression test here would make this much safer. There’s already Bedrock native tool-calling coverage in lib/crewai/tests/agents/test_native_tool_calling.py, especially test_bedrock_agent_kickoff_with_tools_mocked. It would be great to extend that test (or add a nearby Bedrock-specific regression test in the same file) to assert that a Bedrock-shaped tool call like: {"name": "calculator", "toolUseId": "...", "input": {"expression": "15 * 8"}} results in the executed tool receiving {"expression": "15 * 8"} rather than {}. Right now the test seems to validate the final outcome, but not that the Bedrock input payload was preserved through parsing/execution. |
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.
Fixes #5275
Problem
When using crewAI with AWS Bedrock LLMs (e.g. Amazon Nova Pro), tool arguments were silently discarded. The LLM correctly called the tool with the right arguments, but the tool received an empty dict
{}.Root Cause
Line 850 in
crew_agent_executor.py:Bedrock's Converse API returns tool calls as
{"name": "X", "toolUseId": "Y", "input": {...}}— no "function" wrapper. Sofunc_info = {}, andfunc_info.get("arguments", "{}")returns the default string"{}"which is truthy, preventing theorfrom falling through totool_call.get("input", {}).Fix
Changed default from
"{}"toNone:With
Noneas default,func_info.get("arguments")returnsNone(falsy) when no "function" wrapper exists, so theorcorrectly falls through to the Bedrock input format.