Skip to content

fix(bedrock): add missing type field in parallel_tool_calls tool_choi… - #22638

Closed
baniol wants to merge 1 commit into
BerriAI:mainfrom
baniol:fix/bedrock-parallel-tool-calls-claude45
Closed

baniol wants to merge 1 commit into
BerriAI:mainfrom
baniol:fix/bedrock-parallel-tool-calls-claude45

Conversation

@baniol

@baniol baniol commented Mar 3, 2026 •

Copy link
Copy Markdown

Relevant issues

Fixes #22637

Pre-Submission checklist

  • I have Added testing in the tests/test_litellm/ directory
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Type

🐛 Bug Fix

Changes

Problem

parallel_tool_calls: true with tools on Bedrock Claude 4.5+ models fails with:
BedrockException - tool_choice.type: Field required

In map_openai_params(), the _parallel_tool_use_config creates a tool_choice object without the required "type" field. For Claude 4.5+ this gets merged into additionalModelRequestFields and passed directly to the Anthropic model, which rejects it.

Fix

Add "type": "auto" to the tool_choice object in _parallel_tool_use_config.

Testing

  • Updated test_parallel_tool_calls_newer_model_adds_disable_flag to assert type field
  • Added test_parallel_tool_calls_true_includes_type_field — regression test for parallel_tool_calls: True

@vercel

vercel Bot commented Mar 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Error Error Mar 3, 2026 8:44am

Request Review

@CLAassistant

CLAassistant commented Mar 3, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@greptile-apps

greptile-apps Bot commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixes a Bedrock API rejection (tool_choice.type: Field required) when using parallel_tool_calls with Claude 4.5+ models. The fix adds the missing "type": "auto" field to the tool_choice object in _parallel_tool_use_config, which gets passed through additionalModelRequestFields to the Anthropic model on Bedrock.

  • Root cause: The _parallel_tool_use_config constructed a tool_choice dict with only disable_parallel_tool_use, but the Anthropic model requires the type field
  • Fix: Single-line addition of "type": "auto" to the dict
  • Tests: Updated existing test and added a regression test covering parallel_tool_calls=True
  • Note: When both tool_choice and parallel_tool_calls are used together, the hardcoded "auto" type could conflict with the user's intent (pre-existing design concern, not introduced by this PR)

Confidence Score: 4/5

  • This PR is safe to merge — it's a minimal, targeted fix for a clear bug with appropriate test coverage.
  • The change is a single-line addition that fixes a documented Bedrock API rejection. Tests cover both True and False values of parallel_tool_calls. The only concern is a pre-existing design issue around combined tool_choice + parallel_tool_calls usage, which is not introduced by this PR.
  • No files require special attention. The production change is minimal and well-tested.

Important Files Changed

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"]
Loading

Last reviewed commit: e14796b

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

optional_params["_parallel_tool_use_config"] = {
"tool_choice": {
"disable_parallel_tool_use": disable_parallel
"type": "auto",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@fuchengwarrenzhu

fuchengwarrenzhu commented May 21, 2026 •

Copy link
Copy Markdown

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 type: "auto" fixes the base missing-type error, but if the caller combines parallel_tool_calls with explicit tool_choice="required" or a named-tool choice, hardcoding auto loses the caller's tool-choice intent. Current LiteLLM also leaves the Bedrock-native toolConfig.toolChoice in the request while adding the Anthropic additionalModelRequestFields.tool_choice, which can create conflicting tool-choice channels.

I opened draft PR #28509 with the extra cases covered:

  • parallel_tool_calls=True / False include Anthropic type;
  • explicit tool_choice is preserved for both parallel_tool_calls=True and False;
  • tool_choice="required" maps to Anthropic type: "any";
  • named tool choice maps to Anthropic type: "tool", name: ...;
  • the native Bedrock toolConfig.toolChoice is removed when that choice is moved into the Anthropic extension.

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 deselected

Happy to close/adapt that PR if you'd rather fold the edge-case handling into this one.

@ghost

ghost commented May 21, 2026

Copy link
Copy Markdown

🤖 litellm-agent: This PR is currently BLOCKED from merge.

Score: 0/5 ❌

Why blocked:

  • merge conflicts (rebase against base branch) (merge_conflicts, -5 pts)
  • 2 unresolved reviewer concerns (greptile, pr_comment) (unresolved_concern, -1 pts)

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.

Note: This bot is still in beta and might not always work as expected. Please share any feedback via Slack.

@github-actions

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added the stale label Aug 20, 2026
@github-actions github-actions Bot closed this Aug 27, 2026

This branch had an error being deployed

1 failed deployment
Preview — e14796bc Deployed Mar 3, 2026 by vercel[bot]
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 Converse fails with parallel_tool_calls on Claude 4.5+

3 participants