Skip to content

fix: extract Bedrock-style dict tool call arguments correctly (#4495)#4496

Open
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
devin/1771241928-fix-native-tool-call-args
Open

fix: extract Bedrock-style dict tool call arguments correctly (#4495)#4496
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
devin/1771241928-fix-native-tool-call-args

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Feb 16, 2026

fix: extract Bedrock-style dict tool call arguments correctly (#4495)

Summary

One-line fix for a regression where Bedrock-style dict tool calls ({"toolUseId": "...", "name": "...", "input": {...}}) silently lost their arguments, causing _run() to be called with no args.

Root cause: In _handle_native_tool_calls, the expression:

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

For Bedrock dicts without a "function" key, func_info is {}, so .get("arguments", "{}") returns the default string "{}" — which is truthy. The or short-circuits and the actual arguments from tool_call["input"] are never read.

Fix:

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

Without a default, .get("arguments") returns None (falsy), allowing proper fallback to tool_call.get("input").

Review & Testing Checklist for Human

  • Confirm edge case: if an OpenAI response ever has "arguments": "" (empty string, falsy), the fix would now fall through to tool_call.get("input") instead of using the empty string. This should not happen in practice (OpenAI always sends valid JSON strings), but worth a mental trace to confirm acceptability.
  • End-to-end test with an actual Bedrock model using a custom BaseTool with args_schema (like the ParsedBedrockKBRetrieverTool from the issue) to confirm the fix resolves the reported issue. The new unit tests mock the tool call dicts directly and do not go through a real LLM provider.
  • Verify the fix doesn't break OpenAI-style dict tool calls where "function"."arguments" is present (test_openai_dict_tool_call_passes_arguments covers this, but worth a manual trace).

Recommended test plan: Deploy against a Bedrock-backed agent with a custom BaseTool that has required arguments and verify the tool receives its arguments correctly.

Notes

  • Tests index executor.messages[-2] to find the tool result message, relying on the internal message ordering (assistant → tool → reasoning prompt). This is correct per current code but couples tests to implementation detail.
  • All CI checks passed (lint, type-checker, tests across Python 3.10–3.13).
  • Requested by: João
  • Link to Devin run: https://app.devin.ai/sessions/79c3dd11772349d58fe284a62f8c8119

The default value '{}' for func_info.get('arguments', '{}') was a truthy
string that prevented the 'or' operator from falling through to
tool_call.get('input') for Bedrock-style dict tool calls. This caused
tool arguments to be silently replaced with an empty dict, resulting in
_run() being called without required arguments.

Changed to: func_info.get('arguments') or tool_call.get('input') or {}

Added regression tests covering Bedrock-style, OpenAI-style, and
multi-argument dict tool calls.

Co-Authored-By: João <joao@crewai.com>
@devin-ai-integration
Copy link
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

Co-Authored-By: João <joao@crewai.com>
}
]

result = executor._handle_native_tool_calls(
}
]

result = executor._handle_native_tool_calls(
}
]

result = executor._handle_native_tool_calls(
This reproduces the exact scenario from issue #4495 where a custom wrapper
around BedrockKBRetrieverTool fails with '_run() missing 1 required positional argument'.
"""
class InnerResult:
}
]

result = executor._handle_native_tool_calls(
}
]

result = executor._handle_native_tool_calls(
}
]

result = executor._handle_native_tool_calls(
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.

0 participants