litellm/tests/test_litellm/llms/anthropic
Mateo Wang ead8a708bb
fix(bedrock): preserve cache_control for ARN models in /v1/messages adapter (#29823)
* fix(bedrock): preserve cache_control for ARN models in /v1/messages adapter

Bedrock Application Inference Profile ARNs contain neither "anthropic" nor
"claude", so is_anthropic_claude_model could not detect them and the
/v1/messages adapter silently dropped cache_control during the Anthropic to
OpenAI translation. Prompt caching never activated for these models, while the
same profile cached correctly through /v1/chat/completions.

Add an is_bedrock_arn_model check scoped to _add_cache_control_if_applicable so
cache_control is preserved for ARN-based models without broadening the shared
is_anthropic_claude_model helper, which also drives thinking translation.

Fixes #26625

* refactor(bedrock): match :bedrock: ARN service field in is_bedrock_arn_model

Tighten the ARN detection so it pins "bedrock" to the colon-delimited service
field of the ARN rather than matching the substring anywhere. This avoids a
false positive for another service's ARN whose resource name merely contains
"bedrock" (e.g. arn:aws:sagemaker:...:endpoint/my-bedrock-transcriber).
2026-06-16 13:04:42 -07:00
..
chat Add Claude Fable 5 across Anthropic, Bedrock, Vertex AI, and Azure AI (#30064) 2026-06-10 08:50:15 +05:30
experimental_pass_through fix(bedrock): preserve cache_control for ARN models in /v1/messages adapter (#29823) 2026-06-16 13:04:42 -07:00
files fix: encode upstream URL path identifiers 2026-04-29 22:02:39 -07:00
messages test(advisor): add unit tests for max_uses=0, missing model, default fallback 2026-04-11 18:16:56 -07:00
test_anthropic_common_utils.py fix(anthropic): route Claude Opus 4.8 through adaptive thinking (#29702) 2026-06-05 16:19:01 +05:30
test_anthropic_count_tokens_transformation.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_anthropic_files_and_batches.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_anthropic_structured_output.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_azure_ai_cache_pricing.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_cost_calculation_dict_safety.py fix: completion_cost AttributeError on streaming Anthropic web_search responses (#26153) (#27346) 2026-06-10 21:20:11 -07:00
test_count_tokens_oauth.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_message_sanitization.py fix(anthropic, mcp): sanitize tool names to match Anthropic's [a-zA-Z0-9_-]{1,128} pattern (#26788) 2026-05-06 00:00:36 +00:00