Skip to content

fix: prevent Bedrock tool call arguments from being silently dropped#5276

Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1775347433-fix-bedrock-tool-args
Open

fix: prevent Bedrock tool call arguments from being silently dropped#5276
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1775347433-fix-bedrock-tool-args

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot commented Apr 5, 2026

Summary

Fixes #5275. When using AWS Bedrock LLMs, tool call arguments were silently discarded, causing tools to receive {} instead of the actual parameters.

Root cause: In _parse_native_tool_call, the dict-branch used func_info.get("arguments", "{}"). Bedrock tool calls have no "function" wrapper, so func_info is {}. The .get("arguments", "{}") returns the default "{}" — a truthy string — which short-circuits the or, and tool_call.get("input", {"city": "Paris"}) is never evaluated.

Fix: Remove the truthy default so the or-chain falls through correctly:

# Before (broken for Bedrock)
func_args = func_info.get("arguments", "{}") or tool_call.get("input", {})

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

This aligns with extract_tool_call_info in agent_utils.py (line 1224), which already uses the correct pattern.

Review & Testing Checklist for Human

  • Verify that OpenAI-format dict tool calls (with "function": {"arguments": ...}) still work — the arguments value is a non-empty JSON string (truthy), so the or should not fall through
  • Consider edge case: if arguments is ever an empty string "", it now falls through to input instead of returning "{}". This should be benign (empty string is invalid JSON anyway) but worth confirming no provider sends it
  • Recommended test plan: Run a Bedrock-backed agent with a tool that has required parameters (e.g. the TravelTool from the issue) and confirm the tool receives the correct arguments instead of {}

Notes

  • The parallel implementation in agent_utils.py:extract_tool_call_info already had the correct pattern and was not affected
  • 7 new unit tests added covering Bedrock dict, OpenAI dict, empty args, and nested args for both _parse_native_tool_call and extract_tool_call_info

Link to Devin session: https://app.devin.ai/sessions/f9045bdaa79642948bb2f734e0de5d79


Note

Low Risk
Low risk, localized change to native tool-call argument extraction plus new unit coverage; main risk is subtle behavior change when function.arguments is missing/empty causing fallback to input/{}.

Overview
Fixes native tool-call parsing so Bedrock-style dict tool calls no longer drop their input arguments (removes the truthy default "{}" and falls through to tool_call["input"] or {}).

Adds regression/unit tests covering Bedrock vs OpenAI dict formats, empty-args behavior, and nested Bedrock inputs for both CrewAgentExecutor._parse_native_tool_call and agent_utils.extract_tool_call_info.

Reviewed by Cursor Bugbot for commit c0c1920. Bugbot is set up for automated code reviews on this repo. Configure here.

When using AWS Bedrock LLMs, tool arguments were silently discarded
because func_info.get('arguments', '{}') returned the truthy default
'{}' string, preventing the 'or' fallback to tool_call.get('input')
which contains the actual Bedrock arguments.

Changed the default from '{}' to None (by omitting it) so that when
no 'function' wrapper is present (Bedrock format), the or-chain
correctly falls through to read tool_call['input'].

Fixes #5275

Co-Authored-By: João <joao@crewai.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

Prompt hidden (unlisted session)

@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions github-actions bot added the size/M label Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Bedrock tool call arguments silently dropped — tool invoked with empty input

0 participants