test: lock in Bedrock and OpenAI _parse_native_tool_call arg handling (#4972)#5898
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR adds regression test coverage for the ChangesNative tool-call parsing regression tests
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi maintainers, this PR is from a fork and the required CI workflows (Lint, Run Type Checks, Run Tests on 3.10 to 3.13) are sitting in the action_required state, which is the first-time-contributor gate. Could one of you approve the workflow runs so the required checks can complete and the PR can be merged? The change is test-only (one new file under lib/crewai/tests/agents/) and locks in the Bedrock arg-handling fix from #4972. Happy to rebase if you need anything else. Thanks. |
The runtime fix from commit 25fcf39 handled the Bedrock Converse dict shape that previously dropped tool arguments, but no test locked the behaviour in. Add parametrized cases asserting both the Bedrock {'name', 'input', 'toolUseId'} shape and the OpenAI {'function': {'name', 'arguments'}} shape round-trip through _parse_native_tool_call without losing args. Fixes crewAIInc#4972
dc8f655 to
3a0709b
Compare
Summary
Issue #4972 reported that AWS Bedrock Converse tool calls had their arguments silently dropped because the dict branch of
_parse_native_tool_callused a truthy default infunc_info.get("arguments", "{}"), which short-circuited theorbefore the Bedrockinputkey was read.The runtime fix shipped in commit 25fcf39 (
fix: preserve Bedrock tool call arguments by removing truthy default), but no test locked in the behaviour, so the issue stayed open. This PR adds the regression coverage.What is covered
A new
TestParseNativeToolCallclass inlib/crewai/tests/agents/test_native_tool_calling.pywith parametrized cases:{"name": ..., "input": {...}, "toolUseId": ...}— assertstoolUseIdis used as call id, the tool name is parsed, andinputround-trips as the args dict.{"id": ..., "function": {"name": ..., "arguments": "...json..."}}— asserts theidis preserved and the JSONargumentsstring is returned unchanged.input(and is not the empty dict that triggered the bug).I verified the tests catch the regression by temporarily restoring the buggy default (
func_info.get("arguments", "{}")): the two Bedrock cases fail with'{}' == {...}and the OpenAI case still passes, exactly matching the bug surface in the issue.This is a test-only PR, no source changes.
Test plan
pytest tests/agents/test_native_tool_calling.py -v -k parse_native_tool_callpasses (3/3)Fixes #4972
Summary by CodeRabbit