Skip to content

fix(bedrock): extract tool arguments from Bedrock's input field#4764

Open
giulio-leone wants to merge 1 commit intocrewAIInc:mainfrom
giulio-leone:fix/bedrock-tool-args-extraction
Open

fix(bedrock): extract tool arguments from Bedrock's input field#4764
giulio-leone wants to merge 1 commit intocrewAIInc:mainfrom
giulio-leone:fix/bedrock-tool-args-extraction

Conversation

@giulio-leone
Copy link
Contributor

@giulio-leone giulio-leone commented Mar 8, 2026

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):

func_args = func_info.get("arguments", "{}") or tool_call.get("input", {})

When func_info (from tool_call.get("function", {})) is an empty dict (Bedrock has no function key), .get("arguments", "{}") returns the default string "{}". Since "{}" is truthy, the or operator never evaluates tool_call.get("input").

Result: Bedrock's actual arguments in input are silently dropped.

Fix

Use None as the sentinel so or falls through correctly:

func_args = (
    func_info.get("arguments")
    or tool_call.get("input")
    or "{}"
)

Verified Locally

=== Bedrock tool call ===
OLD CODE: '{}'       <-- BUG: returns empty string instead of args
NEW CODE: {'query': 'AWS Bedrock features'}  <-- FIXED: returns actual args

=== OpenAI tool call (regression) ===
OLD CODE: '{"query": "test"}'
NEW CODE: '{"query": "test"}'
MATCH: True          <-- No regression

Tests

Added 7 unit tests covering:

  • Bedrock dict with input field (the reported bug)
  • OpenAI dict with function.arguments (regression)
  • Bedrock dict without function key
  • Empty input dict
  • Neither function nor input (fallback)
  • OpenAI-style object with .function attribute
  • Bedrock-style object with .name and .input attributes

All 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_call to correctly extract arguments from AWS Bedrock tool calls by preferring function.arguments when present, otherwise falling back to the dict’s input field (instead of prematurely defaulting to the string "{}").

Adds focused unit coverage in test_bedrock_tool_args.py for 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.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] AWS Bedrock tool calls extract empty arguments - uses wrong field name

1 participant