Skip to content

fix: preserve Bedrock Converse API tool arguments in _parse_native_tool_call#4985

Open
guoyangzhen wants to merge 1 commit intocrewAIInc:mainfrom
guoyangzhen:fix/bedrock-tool-args
Open

fix: preserve Bedrock Converse API tool arguments in _parse_native_tool_call#4985
guoyangzhen wants to merge 1 commit intocrewAIInc:mainfrom
guoyangzhen:fix/bedrock-tool-args

Conversation

@guoyangzhen
Copy link

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:

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

Bedrock returns tool calls as {"name": "...", "input": {...}, "toolUseId": "..."} — no "function" key. So func_info is {}, and func_info.get("arguments", "{}") returns the default string "{}". Since "{}" is truthy, the or short-circuits and tool_call["input"] is never evaluated.

Fix

Remove the default value from .get("arguments") so it returns None when the key is absent, allowing the or to fall through to tool_call.get("input"):

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

Behavior by provider:

Provider tool_call structure Before fix After fix
OpenAI {"function": {"arguments": "{...}"}} "{...}" "{...}"
Anthropic (direct) {"input": {...}} (has attr) Handled earlier Handled earlier
Bedrock (dict) {"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.

…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
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] _parse_native_tool_call drops Bedrock Converse API tool arguments — always passes empty dict

1 participant