Repository navigation
Conversation
…ce for Claude 4.5+
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryFixes a Bedrock API rejection (
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| litellm/llms/bedrock/chat/converse_transformation.py | Adds required "type": "auto" field to the _parallel_tool_use_config tool_choice dict. Fixes Bedrock rejection for Claude 4.5+ models when parallel_tool_calls is set. Minor concern: hardcoded "auto" may conflict with explicit tool_choice when both are used together. |
| tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py | Adds assertion for type field in existing test and a new regression test for parallel_tool_calls=True. Tests are mock-based with no network calls. Good coverage for both True and False values of parallel_tool_calls. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["User sets parallel_tool_calls + tools"] --> B["map_openai_params()"]
B --> C["Build _parallel_tool_use_config"]
C --> D["tool_choice: {type: 'auto', disable_parallel_tool_use: bool}"]
D --> E["_prepare_request_params()"]
E --> F{"is_claude_4_5_on_bedrock?"}
F -->|Yes| G["Merge into additionalModelRequestFields"]
F -->|No| H["Drop _parallel_tool_use_config"]
G --> I["Bedrock API Request"]
H --> I
I --> J["additionalModelRequestFields.tool_choice\nincluding required 'type' field"]
Last reviewed commit: e14796b
| optional_params["_parallel_tool_use_config"] = { | ||
| "tool_choice": { | ||
| "disable_parallel_tool_use": disable_parallel | ||
| "type": "auto", |
There was a problem hiding this comment.
Hardcoded "auto" may conflict with explicit tool_choice
When a user passes both tool_choice="required" and parallel_tool_calls=True, the native Converse toolChoice will be set to {"any": {}} (via map_tool_choice_values), but additionalModelRequestFields.tool_choice.type will always be "auto". Since Bedrock forwards additionalModelRequestFields directly to the Anthropic model, this could override the user's intended tool-forcing behavior.
This is a pre-existing design concern (not introduced by this PR), but worth noting: consider deriving the type from the user's explicit tool_choice if one is present in non_default_params, rather than always defaulting to "auto". For example, mapping "required" → "any" and {"function": {"name": ...}} → "tool".
There was a problem hiding this comment.
Agreed — this is a pre-existing design concern. The auto default matches the Anthropic API's default when no tool_choice is specified, which is the common case here (e.g. Zed editor sends parallel_tool_calls: true without explicit tool_choice). Deriving the type from an explicit tool_choice param would be a good follow-up enhancement but is beyond the scope of this bug fix.
|
Thanks for opening this. I hit the same issue while adding a temporary downstream patch for Bedrock Claude tool calls, and the current contribution base still seems to need the fix. One edge case we found downstream: adding I opened draft PR #28509 with the extra cases covered:
Focused local check on the draft PR branch: UV_CACHE_DIR=/private/tmp/uv-cache-litellm uv run --no-sync pytest tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py -k parallel_tool_calls -q
# 9 passed, 119 deselectedHappy to close/adapt that PR if you'd rather fold the edge-case handling into this one. |
|
🤖 litellm-agent: This PR is currently BLOCKED from merge. Score: 0/5 ❌ Why blocked:
Details: Score docked for: merge conflicts (rebase against base branch); 2 unresolved reviewer concerns (greptile, pr_comment). 11 unrelated CI failures unique to this PR (Vercel, test (root), test (llms-vertex) (+8 more)) — not related to this diff but worth a glance. Fix the issues above and push an update — the bot will re-review automatically.
|
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Relevant issues
Fixes #22637
Pre-Submission checklist
tests/test_litellm/directorymake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewType
🐛 Bug Fix
Changes
Problem
parallel_tool_calls: truewithtoolson Bedrock Claude 4.5+ models fails with:BedrockException - tool_choice.type: Field requiredIn
map_openai_params(), the_parallel_tool_use_configcreates atool_choiceobject without the required"type"field. For Claude 4.5+ this gets merged intoadditionalModelRequestFieldsand passed directly to the Anthropic model, which rejects it.Fix
Add
"type": "auto"to thetool_choiceobject in_parallel_tool_use_config.Testing
test_parallel_tool_calls_newer_model_adds_disable_flagto asserttypefieldtest_parallel_tool_calls_true_includes_type_field— regression test forparallel_tool_calls: True