litellm/tests/unit/llms/bedrock/chat
Mateo Wang b750fb26bd
fix(bedrock): send Converse extra_body fields instead of a literal extra_body object (#55398)
* fix(bedrock): send Converse extra_body fields instead of a literal extra_body object

Bedrock Converse got the whole extra_body object as one additionalModelRequestFields entry and answered
400 "Unknown parameter: 'extra_body'", with or without drop_params. The fields inside extra_body are now
merged into the request params the same way top-level fields are, with extra_body winning a name clash.
A non-object extra_body is dropped under drop_params and answers 400 without it.

* fix(bedrock): merge Converse extra_body before the tool and guardrail checks

Tools or guardrailConfig sent only inside extra_body are now seen by the
orphaned tool block and guarded text checks, and an extra_body
output_config gets the same effort cap as a top-level one. The merge
builds a new dict, so the caller's params keep neither the fields nor the
internal marker

* fix(bedrock): keep LiteLLM's own Converse keys out of extra_body and drop routing keys

The extra_body merge stays in the Converse transform, after the handler has read stream,
the AWS keys, endpoint and region from the top level, so extra_body can no longer change
how LiteLLM sends the call. The Converse branch in completion() removes the deployment's
additional_drop_params keys from extra_body before every attempt, the native output
retry included, and the transform also removes model. Strict tools inside extra_body get
the retry without strict, and tool calls written as text are parsed against the
extra_body tools. Adds regression tests for each.

* fix(bedrock): key extra_body in the response cache, bill its service tier, and reject malformed tools and config blocks

* fix(bedrock): keep cost on the served-tier path instead of reading extra_body

* fix(bedrock): bill a streamed Converse call at the tier its metadata event reports

Bedrock ConverseStream sends no service tier header. It reports the served
tier only in the final metadata event, which arrives after the finish chunk,
so the stream wrapper dropped it and a streamed priority call billed at the
standard rate. The Converse stream parser now reads serviceTier from the
metadata event, and the usage chunk the stream wrapper builds after the
finish chunk keeps the upstream chunk's service_tier, which is the chunk
cost tracking reads. Every other chunk is built as before.

* fix(streaming): drop a usage-stripped chunk that carries only service_tier

* fix(bedrock): pass a pre-formatted Bedrock tool block through as the caller sent it

Validating a systemTool block against the typed ToolBlock dropped any key the type does not list, so the block now goes to Bedrock unchanged, as it did before this branch

* fix(bedrock): keep the response_format tool when extra_body tools is null

* fix(bedrock): keep top-level tools when extra_body has no tools key

A missing extra_body.tools no longer replaces the caller's top-level tools with only the response_format tool. Only an explicit tools key in extra_body, null included, takes over the tools list

* fix(bedrock): treat a null extra_body tools as no tools and honor a string drop_params
2026-12-01 19:07:22 +00:00
..
agentcore fix(streaming)!: fail a stream that ends without a finish reason (#47665) 2026-10-31 11:29:26 -07:00
chat_completions fix(bedrock): preserve native chat content cache checkpoints (#53322) (#53370) 2026-11-21 12:15:03 -08:00
invoke_transformations fix(bedrock): send pass-through calls the model id chat completions sends (#53836) 2026-11-25 18:42:28 -08:00
mantle fix(anthropic)!: send extra_body fields at the top level of the Messages request (#48373) 2026-11-20 06:52:56 -08:00
__init__.py test(unit): make every tests/unit directory a package so pytest collection is unique 2026-09-20 11:50:59 +00:00
test_bedrock_converse_handler.py fix(bedrock): send native chat and Responses calls to aws_bedrock_runtime_endpoint like Converse (#50582) 2026-11-19 16:40:23 -08:00
test_bedrock_gpt_oss.py test: move the unit half of 126 mixed legacy files into tests/unit (#45090) 2026-10-07 14:07:43 -07:00
test_converse_transformation.py fix(bedrock): send Converse extra_body fields instead of a literal extra_body object (#55398) 2026-12-01 19:07:22 +00:00
test_converse_transformation_nova_2.py fix(bedrock): drop another model's signed thinking when replaying to a non-Claude Converse target (#50073) 2026-11-06 03:15:49 -08:00
test_invoke_handler.py fix(sagemaker,bedrock): answer 502 when a 200 AWS event stream decodes to no events or ends mid-frame (#53482) 2026-11-22 23:59:32 +00:00
test_mistral_config.py test: migrate tests/llm_translation into unit, integration and e2e tiers (#45759) 2026-10-11 07:58:53 +00:00
test_native_output_fallback.py feat(bedrock): default to native structured output on Opus 5.5, Fable 5.1, Sonnet 5 and Haiku 5.5 (#50221) 2026-11-06 09:38:00 -08:00
test_service_tier.py fix(gateway): serve messages drop, summary and timeout settings like Python (#51236) 2026-11-25 09:26:12 +00:00
test_streaming_choice_index.py refactor: expose core private helpers under public names (#44871) 2026-10-07 00:05:27 +00:00
test_tool_result_images.py fix(bedrock): keep GPT tool-result images beside the tool result (#45579) 2026-10-09 18:02:23 -07:00
test_tool_use_ids.py fix(mistral): map tool call ids to Mistral's 9-char shape on Vertex AI and Bedrock (#53416) 2026-11-22 21:48:55 +00:00
test_writer_palmyra.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00