fix(bedrock): extract tool arguments from Bedrock's input field#4764
Open
giulio-leone wants to merge 1 commit intocrewAIInc:mainfrom
Open
fix(bedrock): extract tool arguments from Bedrock's input field#4764giulio-leone wants to merge 1 commit intocrewAIInc:mainfrom
giulio-leone wants to merge 1 commit intocrewAIInc:mainfrom
Conversation
The `_parse_native_tool_call` method's dict branch used:
```python
func_args = func_info.get("arguments", "{}") or tool_call.get("input", {})
```
Since `.get("arguments", "{}")` returns the default string `"{}"`
(which is truthy), the `or` operator never evaluates
`tool_call.get("input")`. Bedrock tool calls — which use `input`
instead of `function.arguments` — always received empty `"{}"` args.
Fix: use `None` as the sentinel so `or` falls through correctly:
```python
func_args = func_info.get("arguments") or tool_call.get("input") or "{}"
```
Fixes crewAIInc#4748
Signed-off-by: Giulio Leone <6887247+giulio-leone@users.noreply.github.com>
afc22cc to
2742ee7
Compare
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
AWS Bedrock tool calls always receive empty arguments
{}regardless of what the LLM provides. This affects all Bedrock models (Nova Pro, Nova Lite, Claude via Bedrock, etc.).Bedrock tool call format:
{"toolUseId": "tooluse_abc", "name": "search_tool", "input": {"query": "AWS Bedrock features"}}OpenAI tool call format:
{"id": "call_xyz", "function": {"name": "search_tool", "arguments": '{"query": "test"}'}}Root Cause
In
_parse_native_tool_call(line 850):When
func_info(fromtool_call.get("function", {})) is an empty dict (Bedrock has nofunctionkey),.get("arguments", "{}")returns the default string"{}". Since"{}"is truthy, theoroperator never evaluatestool_call.get("input").Result: Bedrock's actual arguments in
inputare silently dropped.Fix
Use
Noneas the sentinel soorfalls through correctly:Verified Locally
Tests
Added 7 unit tests covering:
inputfield (the reported bug)function.arguments(regression)functionkeyinputdictfunctionnorinput(fallback).functionattribute.nameand.inputattributesAll pass.
Fixes #4748
Note
Low Risk
Small, localized change in native tool-call parsing plus new unit tests; low risk of regression beyond how dict-based tool calls choose their argument source.
Overview
Fixes
CrewAgentExecutor._parse_native_tool_callto correctly extract arguments from AWS Bedrock tool calls by preferringfunction.argumentswhen present, otherwise falling back to the dict’sinputfield (instead of prematurely defaulting to the string"{}").Adds focused unit coverage in
test_bedrock_tool_args.pyfor Bedrock dict/object tool calls and OpenAI-style regressions, including fallback behavior when neither arguments source is provided.Written by Cursor Bugbot for commit 2742ee7. This will update automatically on new commits. Configure here.