crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[BUG] _parse_native_tool_call drops Bedrock Converse API tool arguments — always passes empty dict

Open sajilkumarmk opened this issue 8 months ago • 7 comments

Description

When using AWS Bedrock as the LLM provider with native function calling, all tool arguments are silently dropped. Every tool call receives an empty dict {} instead of the actual arguments, causing pydantic validation failures on any tool with required parameters.

Steps to Reproduce

  1. Configure a crewai project with BedrockCompletion as the LLM (any Claude model via Converse API)
  2. Create a custom BaseTool with required arguments (e.g. a tool with search_query: str in its args_schema)
  3. Create a crew/agent that uses this tool
  4. Run the crew with kickoff() or kickoff_async() 5 .Observe that every tool call fails with Field required [type=missing, input_value={}, input_type=dict]

Expected behavior

The agent should pass the arguments from the Bedrock Converse API response (from the "input" field) to the tool. For example, if the LLM returns {"name": "my_tool", "input": {"search_query": "test"}, "toolUseId": "abc"}, the tool should receive search_query="test".

Screenshots/Code snippets

Error output (repeats every iteration until max iterations):

Tool 'search_in_user_knowledgebase' arguments validation failed: 1 validation error for SearchUserKnowledgebaseToolSchema search_query Field required [type=missing, input_value={}, input_type=dict] For further information visit https://errors.pydantic.dev/2.11/v/missing Expected arguments: {"search_query": {"description": "Mandatory semantic search query", "title": "Search Query", "type": "string"}} Required: ["search_query"] Bug location — crewai/agents/crew_agent_executor.py, method _parse_native_tool_call, dict handling branch:

func_info = tool_call.get("function", {}) func_args = func_info.get("arguments", "{}") or tool_call.get("input", {}) Bedrock returns {"name": "...", "input": {...}, "toolUseId": "..."} — no "function" key. So func_info is {}, and func_info.get("arguments", "{}") returns the default "{}" (a truthy string). The or short-circuits and tool_call["input"] is never read.

Operating System

macOS Monterey

Python Version

3.12

crewAI Version

1.11.0

crewAI Tools Version

1.11.0

Virtual Environment

Poetry

Evidence

Reproducing the bug in isolation:

func_info = {} # No "function" key in Bedrock format tool_call = {"name": "my_tool", "input": {"search_query": "test"}, "toolUseId": "abc"}

Current (broken):

func_args = func_info.get("arguments", "{}") or tool_call.get("input", {}) print(func_args) # "{}" — truthy default prevents fallthrough

Fixed:

func_args = func_info.get("arguments") or tool_call.get("input") or "{}" print(func_args) # {"search_query": "test"} — correct

Possible Solution

One-line fix in _parse_native_tool_call (line ~850 of crew_agent_executor.py):

Before (broken):

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

After (fixed):

func_args = func_info.get("arguments") or tool_call.get("input") or "{}" Remove the default "{}" from get("arguments", "{}") so it returns None (falsy) when the key is missing, allowing the or to correctly fall through to tool_call.get("input").

Additional context

This affects ALL Bedrock models using native function calling (the _ainvoke_loop_native_tools / _invoke_loop_native_tools code path). BedrockCompletion.supports_function_calling() returns True, so the native path is always used instead of ReAct when tools are present. The _is_tool_call_list method correctly detects Bedrock-style dicts (line 663-669), but _parse_native_tool_call fails to extract arguments from them. This was likely introduced when native function calling support was added, since the dict branch was written primarily for OpenAI-style {"function": {"name": "...", "arguments": "..."}} format.

sajilkumarmk avatar Mar 20 '26 05:03 sajilkumarmk

Submitted PR #4986 to fix this issue: https://github.com/crewAIInc/crewAI/pull/4986

The fix corrects the fallback logic in _parse_native_tool_call to properly handle Bedrock Converse API format. Please review when you have time. Thanks!

goingforstudying-ctrl avatar Mar 20 '26 14:03 goingforstudying-ctrl

I've submitted a fix for this: #5015

One-line change that removes the truthy default from get() so the or correctly falls through to tool_call input for Bedrock format dicts. Includes 4 regression tests.

r266-tech avatar Mar 22 '26 16:03 r266-tech

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Apr 22 '26 12:04 github-actions[bot]

I traced this through the codebase and it appears this was fixed in commit 25fcf39 (2026-04-12) with the message "fix: preserve Bedrock tool call arguments by removing truthy default".

The fix is in lib/crewai/src/crewai/agents/crew_agent_executor.py inside _parse_native_tool_call. The dict branch now correctly reads func_args = func_info.get("arguments") or tool_call.get("input", {}) so Bedrock-style input is preserved.

Could a maintainer verify and close this if confirmed fixed? Happy to add a regression test if that would help.

VANDRANKI avatar Apr 22 '26 21:04 VANDRANKI

This is exactly the kind of provider-specific tool-call bug that benefits from a small contract test.

I would add a fixture for each native tool-call shape CrewAI supports: OpenAI-style function.arguments, Bedrock Converse input, and any provider format that carries tool args differently. The assertion should verify the parsed tool name, arguments, and tool id before validation runs. That way a future change cannot silently convert a valid tool call into {} and make the agent loop look like a planning failure.

andrewclayman avatar Jun 02 '26 10:06 andrewclayman

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jul 02 '26 12:07 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Jul 07 '26 13:07 github-actions[bot]