Skip to content

test(agents): cover Bedrock Converse toolUse arg parsing#6192

Open
HumphreySun98 wants to merge 1 commit into
crewAIInc:mainfrom
HumphreySun98:test/bedrock-converse-tool-args
Open

test(agents): cover Bedrock Converse toolUse arg parsing#6192
HumphreySun98 wants to merge 1 commit into
crewAIInc:mainfrom
HumphreySun98:test/bedrock-converse-tool-args

Conversation

@HumphreySun98

@HumphreySun98 HumphreySun98 commented Jun 16, 2026

Copy link
Copy Markdown

Summary

Bedrock's Converse API returns tool calls shaped as {"toolUseId": ..., "name": ..., "input": {...}} — no function wrapper and no arguments key — so CrewAgentExecutor._parse_native_tool_call must read input. Today it does (func_info.get("arguments") or tool_call.get("input", {})), but this path has no offline coverage: the existing Bedrock tests are gated behind live AWS credentials (RUN_BEDROCK_LIVE_TESTS), leaving the arg extraction unprotected against regression.

This is exactly what #4972 reported (Converse args dropped, every tool receiving {}). The bug is already fixed at main; this PR locks the behavior in.

Tests

Adds two credential-free unit tests to TestNativeToolCallingJsonParseError:

  • test_bedrock_converse_tooluse_args_pass_through — a raw Converse toolUse dict yields its input as the args (not {}).
  • test_bedrock_converse_tooluse_args_reach_the_tool — those args actually execute the tool with real values.

Both would have failed under the buggy behavior described in the issue.

Refs #4972


This PR was authored with Claude Code. Per CONTRIBUTING.md, AI-generated contributions require the llm-generated label — I don't have triage permission to set it, so could a maintainer please add it? 🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added regression tests for tool calling to improve reliability of tool input argument processing.

Bedrock's Converse API returns tool calls as
{"toolUseId": ..., "name": ..., "input": {...}} with no "function" wrapper
or "arguments" key, so _parse_native_tool_call must read "input". This path
had no offline coverage — the existing Bedrock tests are gated behind live
AWS credentials — leaving the arg extraction unprotected against regression
(see crewAIInc#4972, where Converse args were dropped and tools received {}).

Add credential-free unit tests asserting the args are extracted and reach
the tool with their real values.

Refs crewAIInc#4972

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 320b6cbf-a901-49d1-8de4-0c511ae83b42

📥 Commits

Reviewing files that changed from the base of the PR and between e9d568d and 4b0d479.

📒 Files selected for processing (1)
  • lib/crewai/tests/agents/test_native_tool_calling.py

📝 Walkthrough

Walkthrough

Two regression tests are added to test_native_tool_calling.py for the Bedrock Converse provider. The first test verifies that func_args is extracted from the input field of a toolUse block. The second test verifies those parsed arguments propagate through _execute_single_native_tool_call to produce the expected tool output.

Changes

Bedrock Converse toolUse regression tests

Layer / File(s) Summary
toolUse argument parsing and execution tests
lib/crewai/tests/agents/test_native_tool_calling.py
Adds a unit test asserting func_args is read from the toolUse block's input field rather than defaulting to {}, and an end-to-end test confirming those arguments reach the tool implementation via _execute_single_native_tool_call.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test(agents): cover Bedrock Converse toolUse arg parsing' directly and specifically describes the main change—adding unit tests for Bedrock Converse tool argument parsing, which matches the file changes and PR objectives.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant