litellm/tests/unit/llms/bedrock
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
..
batches fix(batches): keep the endpoint a batch was created for on retrieve, cancel and cost polling (#50784) 2026-11-24 05:42:08 -08:00
chat fix(bedrock): send Converse extra_body fields instead of a literal extra_body object (#55398) 2026-12-01 19:07:22 +00:00
count_tokens fix(token_counter): count an Anthropic fallback block as zero on every count route (#54006) 2026-11-24 03:32:34 -08:00
embed fix(embeddings): send request-shaped extra_body fields at the provider's documented path (#54273) 2026-11-25 13:29:52 -08:00
files fix(anthropic): answer 400 naming a malformed thinking_blocks instead of 500 (#53762) 2026-11-24 03:06:47 -08:00
image test: move 81 legacy live tests in pass-through, spend, batches, audio, search, guardrails, image and ocr dirs offline (#45288) 2026-10-08 02:38:12 -07:00
image_edit refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
image_generation test: move the unit half of 126 mixed legacy files into tests/unit (#45090) 2026-10-07 14:07:43 -07:00
invoke_agent 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
messages fix(bedrock): stop naming typed tools on Bedrock invoke /v1/messages so toolset entries reach Claude (#51756) 2026-11-24 02:44:38 -08:00
passthrough fix(bedrock): send pass-through calls the model id chat completions sends (#53836) 2026-11-25 18:42:28 -08:00
realtime test(unit): make 21 flaky unit tests deterministic (#54785) 2026-11-26 20:48:13 -08:00
rerank refactor(types): replace Any with proven types in 137 files (#44478) 2026-10-05 11:01:45 -07:00
responses fix(bedrock): send native chat and Responses calls to aws_bedrock_runtime_endpoint like Converse (#50582) 2026-11-19 16:40:23 -08:00
search fix(streaming): keep merged think tags balanced and split SSE lines only on CR/LF (#48755) 2026-10-28 17:00:29 -07:00
vector_stores fix(bedrock): name each knowledge base search hit after its source document from the result location (#54575) 2026-11-30 20:09:53 +00: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
event_loop_probe.py test(bedrock): detect Vault reads on the event-loop thread (#47597) 2026-10-20 10:45:04 -07:00
slow_upstream.py fix(router)!: bound fake-streamed calls by the request timeout, not stream_timeout (#47162) 2026-10-17 22:08:02 +00:00
test_anthropic_beta_support.py refactor(llms): rename model-version transformation files to family names (#48509) 2026-10-26 18:53:16 -07:00
test_base_aws_llm.py fix(bedrock): treat an empty api_base or runtime endpoint as unset (#51244) 2026-11-24 00:36:07 +00:00
test_bedrock_common_utils.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_bedrock_model_listing.py fix(bedrock): discover models through the configured control-plane endpoint (#50840) 2026-11-24 14:09:25 -08:00
test_bedrock_ssl_verify.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_claude_platform_provider.py fix(anthropic): drop unsigned thinking blocks before /v1/messages reaches Claude (#51793) 2026-11-24 05:30:55 +00:00
test_converse_context_management.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_cost_calculation.py feat(cost): price Claude token calls, budget holds and auth price checks in Rust (#52484) 2026-11-23 22:00:28 +00:00
test_cross_region_inference_profile_mapping.py feat(bedrock): serve gpt-5.6+ chat completions natively by default, with chat_completions/ opt-in for gpt-oss and grok (#44307) 2026-10-02 19:55:54 -07:00
test_guardrail_attachments.py fix(guardrails): scan or refuse attachments in the bedrock guardrail (#43383) 2026-10-10 16:48:37 -07:00
test_mantle.py feat(messages): serve bedrock mantle messages on rust only (#52328) 2026-11-18 17:36:06 -08:00
test_nova_imported_models.py fix(bedrock): route a Bedrock model id with no Invoke provider to Converse (#43290) 2026-10-30 06:27:59 -07:00
test_request_metadata.py feat(messages): serve bedrock claude_platform messages on rust only (#52681) 2026-11-19 14:34:02 -08:00
test_session_identity.py feat(bedrock): derive STS session tags and session name from caller identity (#52978) 2026-11-19 17:11:09 -08:00
test_web_identity_session_policy.py fix(bedrock): discover models through the configured control-plane endpoint (#50840) 2026-11-24 14:09:25 -08:00