litellm/tests/test_litellm/llms/bedrock
devin-ai-integration[bot] fecc8c8f74
feat(bedrock): serve the OpenAI models on bedrock-runtime's native Responses API (internal copy of #38489) (#42767)
* feat(bedrock): serve the OpenAI models on bedrock-runtime's native Responses API

AWS serves the OpenAI models on bedrock-runtime through an OpenAI-compatible
surface at /openai/v1/responses, alongside Converse. LiteLLM had no Responses
config for the bedrock provider, so /v1/responses fell back to the Chat
Completions bridge and was translated into Converse. A realistic Codex session
does not survive that translation: its function_call / function_call_output
history becomes Converse toolUse / toolResult blocks with no toolConfig, and
Converse rejects the request outright.

Add a Responses config for that surface, opted into per model from the price-map
supported_endpoints so models without the signal keep the bridge exactly as
before. Auth is Bearer when a Bedrock API key is present, SigV4 otherwise.

Both Bedrock endpoints reject the Codex history item types agent_message,
context_compaction and local_shell_call, so the normalization bedrock_mantle
carried privately moves into a shared module and both providers use it. They are
history items, so they only bite from the second turn onward -- a first-turn
smoke test passes and hides the problem. Verified against bedrock-runtime with
global.openai.gpt-5.6-sol: additional_tools is accepted there (unlike on
bedrock-mantle) while those three types are rejected, so the two endpoints do
not share one validator and each provider opts in explicitly.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(bedrock): build the Responses endpoint from the region's partition suffix

get_complete_url hardcoded amazonaws.com in an f-string, so every non-commercial
partition got the wrong host: cn-north-1 resolved to amazonaws.com instead of
amazonaws.com.cn, and GovCloud/ISO regions were wrong the same way. Defer to
BaseAWSLLM._select_default_endpoint_url, which this config already inherits and
which resolves the suffix per partition.

test_no_fstring_hardcodes_the_commercial_dns_suffix scans the whole tree, so it
caught this even though it is not one of this PR's test files. Register the
config in ENDPOINT_BUILDERS so the cn/GovCloud endpoint sweep covers this
surface from now on rather than only the f-string guard.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* feat(bedrock): opt the gpt-6 family into the native Responses API

* fix(bedrock): drop the Responses tool types bedrock-runtime rejects

Codex sends a web_search tool on every turn. api.openai.com runs that tool
itself, and the Converse bridge dropped it silently, but bedrock-runtime's
native Responses endpoint rejects the whole request with 400 "web search is
not supported for this request". Filter the request's tools down to the
types bedrock-runtime's own validation error names, logging what was dropped,
through a helper shared with the Mantle route, which already did the same.

* fix(bedrock): emulate file_search and collapse custom Responses paths

* fix(bedrock): keep background and remote image inputs working on the native Responses route

* fix(bedrock): inline remote images inside tool outputs on the native Responses route

* fix(bedrock): inline remote computer screenshots on the native Responses route

---------

Co-authored-by: Leonardo Freitas dos Santos <leonardo.freitas.s@outlook.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-09-23 15:12:39 -07:00
..
batches fix(bedrock): treat blank AWS_S3_* env vars as unset for batch jobs (#42528) 2026-09-22 17:55:22 -07:00
chat chore(prices): sync AWS Bedrock prices and sources from the AWS price list (#42632) 2026-09-22 20:24:28 -07:00
embed Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_bedrock_aws_session_tags 2026-09-10 09:42:22 -07:00
messages/invoke_transformations fix(bedrock): stream /v1/messages Invoke bytes through instead of holding them in a 1024-byte chunker (#42607) 2026-09-22 20:01:56 -07:00
passthrough/guardrail_translation test(llms): migrate phase 5 provider unit tests to tests/unit 2026-09-20 07:50:38 +00:00
rerank test(llms): migrate phase 5 provider unit tests to tests/unit 2026-09-20 07:50:38 +00:00
responses feat(bedrock): serve the OpenAI models on bedrock-runtime's native Responses API (internal copy of #38489) (#42767) 2026-09-23 15:12:39 -07:00
search test: unwind environment writes in tests/test_litellm with monkeypatch (#37806) 2026-08-21 20:28:37 -07:00
__init__.py test(batches): add 1:1 test file scaffold for batches component paths (#30529) 2026-06-29 09:22:58 +05:30
event_loop_probe.py refactor: keep the AWS JSON signing helper under llms and bound the probe's refresh wait 2026-09-08 16:20:50 -07:00
test_anthropic_beta_support.py fix(bedrock): allowlist Bedrock Invoke body fields and filter all anthropic-beta values 2026-04-21 11:26:15 -07:00
test_base_aws_llm.py test(bedrock): type the STS recording helper 2026-09-18 11:42:52 -07:00
test_bedrock_common_utils.py fix(bedrock): price bedrock/mantle/<model> deployments from the base model row (#42402) 2026-09-21 20:59:36 -07:00
test_bedrock_ssl_verify.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_claude_platform_provider.py fix(bedrock/claude_platform): strip body params the AWS endpoint rejects (#31203) 2026-09-22 09:57:05 -07:00
test_converse_context_management.py feat(context_management): compact_20260112 polyfill for non-Anthropic providers (#28868) 2026-05-30 09:20:05 -07:00
test_cross_region_inference_profile_mapping.py test: delete assertions that pin vendor cost map facts 2026-09-18 00:28:49 +00:00
test_mantle.py fix(bedrock): send every Mantle beta in the anthropic-beta header on the bedrock/mantle route (#42376) 2026-09-21 18:52:29 -07:00
test_nova_imported_models.py test: run the 30 test files stranded in the second mirror (#37595) 2026-08-20 10:59:43 -07:00
test_request_metadata.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_web_identity_session_policy.py fix(bedrock): grant the AgentCore for-user invoke action in the web identity session policy 2026-09-14 21:31:45 -07:00