Commit Graph
6 Commits
Author SHA1 Message Date
Sameer KankuteandGitHub 57eae8d01c Merge branch 'litellm_internal_staging' into litellm_staging_03_22_2026 2026-04-20 19:56:00 +05:30
Ishaan Jaffer e8461b5b97 style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
Chesars dd7269ee14 fix(bedrock): sort assistant content blocks so text precedes toolUse
When the Responses API converts function_call and message output items
into chat completion messages, they can become two consecutive assistant
messages. The Bedrock Converse transformer merges these into one, but
the merge preserves input order — so if function_call came first, the
toolUse block ends up before the text block.

Claude models (Sonnet 4, Haiku 3.5+) reject this ordering with:
"tool_use ids were found without tool_result blocks immediately after"

Add _sort_bedrock_assistant_content_blocks() that reorders content
blocks within assistant messages: reasoningContent → text → toolUse.
Applied in both sync and async Bedrock Converse transformation paths.

Fixes #24361
2026-03-22 17:18:40 -03:00
Sameer Kankute 15351a93dc Fix: empty assistant message for converse API 2026-02-04 09:50:58 +05:30
07bffddbfa fix(bedrock): deduplicate toolResult and toolUse blocks in Converse message transformation (#20049)
Bedrock rejects requests when toolResult or toolUse blocks within a
single message contain duplicate IDs. The Converse message transformer
merges consecutive tool/assistant messages without checking for
duplicate toolUseId values, causing BedrockException errors.

Add _deduplicate_bedrock_content_blocks() — a generalized helper that
removes duplicate blocks by ID, logs a warning for each dropped
duplicate via verbose_logger, and preserves non-tool blocks (e.g.
cachePoint). Apply it at all four merge sites (sync/async × toolResult/
toolUse).

The Anthropic /messages path was fixed in PR #19324; this applies the
equivalent fix to the Bedrock Converse path.

Fixes #20048

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 18:23:43 +05:30
1cce718551 fix(bedrock): deduplicate tool calls in assistant history (#15178) (#19324)
* fix: Avoid attaching tool calls when a call_id already exists

* fix: Prevent MCP responses from reviving past tool calls via previous_response_id

* test: Parametrize MCP streaming test to cover OpenAI and Anthropic models

* test: Fail MCP streaming test when LiteLLM logs errors during follow-up calls

* test: Let MCP tool-execution mock accept new kwargs for streaming tests

* chore: fix lint error

* docs: Add Google Workload Identity Federation (WIF) documentation to Vertex AI (#19320)

- Added new section documenting WIF support for Vertex AI authentication
- Included SDK and Proxy configuration examples
- Added sample WIF credentials file format for AWS federation
- Mentioned LLM Credentials UI as an alternative for credential management
- Added link to Google Cloud WIF documentation

Co-authored-by: Cursor Agent <cursoragent@cursor.com>

* fix(bedrock): deduplicate tool calls in assistant history (#15178)

* fix(types): add missing Set import to factory.py

---------

Co-authored-by: Yuta Saito <uc4w6c@bma.biglobe.ne.jp>
Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: YutaSaito <36355491+uc4w6c@users.noreply.github.com>
2026-01-19 10:56:49 -08:00