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
2742ee7 to
5af77a8
Compare
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 <[email protected]>
5af77a8 to
310f000
Compare
Contributor
Author
|
Friendly ping — CI is green, tests pass, ready for review whenever convenient. Happy to address any feedback. Thanks! 🙏 |
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
Low risk bugfix limited to native tool-call argument extraction; main risk is subtle behavior changes for dict-style tool calls when
function.argumentsis missing/empty, but new tests cover expected formats.Overview
Fixes
_parse_native_tool_callto correctly extract tool arguments from AWS Bedrock-style tool calls by falling back to the dict’sinputfield whenfunction.argumentsis absent.Adds focused unit tests covering Bedrock dict/object tool calls, OpenAI regression cases, and fallback behavior when no arguments are provided.
Written by Cursor Bugbot for commit 310f000. This will update automatically on new commits. Configure here.