litellm/tests/test_litellm/llms
Ishaan Jaff b87d1f8dad
[Feat] - Ishaan main merge branch (#23596)
* fix(bedrock): respect s3_region_name for batch file uploads (#23569)

* fix(bedrock): respect s3_region_name for batch file uploads (GovCloud fix)

* fix: s3_region_name always wins over aws_region_name for S3 signing (Greptile feedback)

* fix: _filter_headers_for_aws_signature - Bedrock KB (#23571)

* fix: _filter_headers_for_aws_signature

* fix: filter None header values in all post-signing re-merge paths

Addresses Greptile feedback: None-valued headers were being filtered
during SigV4 signing but re-merged back into the final headers dict
afterward, which would cause downstream HTTP client failures.

Made-with: Cursor

* feat(router): tag_regex routing — route by User-Agent regex without per-developer tag config (#23594)

* feat(router): add tag_regex support for header-based routing

Adds a new `tag_regex` field to litellm_params that lets operators route
requests based on regex patterns matched against request headers — primarily
User-Agent — without requiring per-developer tag configuration.

Use case: route all Claude Code traffic (User-Agent: claude-code/x.y.z) to
a dedicated deployment by setting:

  tag_regex:
    - "^User-Agent: claude-code\\/"

in the deployment's litellm_params. Works alongside existing `tags` routing;
exact tag match takes precedence over regex match. Unmatched requests fall
through to deployments tagged `default`.

The matched deployment, pattern, and user_agent are recorded in
`metadata["tag_routing"]` so they flow through to SpendLogs automatically.

* fix(tag_regex): address backwards-compat, metadata overwrite, and warning noise

Three issues from code review:

1. Backwards-compat: `has_tag_filter` was widened to activate on any non-empty
   User-Agent, which would raise ValueError for existing deployments using plain
   tags without a `default` fallback. Fix: only activate header-based regex
   filtering when at least one candidate deployment has `tag_regex` configured.

2. Metadata overwrite: `metadata["tag_routing"]` was overwritten for every
   matching deployment in the loop, leaving inaccurate provenance when multiple
   deployments match. Fix: write only for the first match.

3. Warning noise: an invalid regex pattern logged one warning per header string
   rather than once per pattern. Fix: compile first (catching re.error once),
   then iterate over header strings.

Also adds two new tests covering these cases, and adds docs page for
tag_regex routing with a Claude Code walk-through.

* refactor(tag_regex): remove unnecessary _healthy_list copy

* docs: merge tag_regex section into tag_routing.md, remove standalone page

- Add ## Regex-based tag routing (tag_regex) section to existing
  tag_routing.md instead of a separate page
- Remove tag_regex_routing.md standalone doc (odd UX to have a separate
  page for a sub-feature)
- Remove proxy/tag_regex_routing from sidebars.js
- Add match_any=False debug warning in tag_based_routing.py when regex
  routing fires under strict mode (regex always uses OR semantics)

* fix(tag_regex): address greptile review - security docs, strict-mode enforcement, validation order

- Strengthen security note in tag_routing.md: explicitly state User-Agent
  is client-supplied and can be set to any value; frame tag_regex as a
  traffic classification hint, not an access-control mechanism
- Move tag_regex startup validation before _add_deployment() so an invalid
  pattern never leaves partial router state
- Enforce match_any=False strict-tag policy: when a deployment has both
  tags and tag_regex and the strict tag check fails, skip the regex fallback
  rather than silently bypassing the operator's intent
- Extract per-deployment match logic into _match_deployment() helper to
  keep get_deployments_for_tag() readable
- Add two new tests: strict-mode blocks regex fallback, regex-only
  deployment still matches under match_any=False

* fix(ci): apply Black formatting to 14 files and stabilize flaky caplog tests

- Run Black formatter on 14 files that were failing the lint check
- Replace caplog-based assertions in TestAliasConflicts with
  unittest.mock.patch on verbose_logger.warning for xdist compatibility
- The caplog fixture can produce empty text in pytest-xdist workers
  in certain CI environments, causing flaky test failures

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>
2026-03-14 09:40:00 -07:00
..
amazon_nova/chat
anthropic fix(tests): stabilize 3 failing CI tests 2026-03-13 00:26:31 +00:00
azure Reapply "feat: add model_cost aliases expansion support" 2026-03-12 13:36:57 -03:00
azure_ai feat(azure_ai): show actual model used in Azure Model Router response 2026-03-12 11:41:19 +05:30
base_llm [Fix] BaseModelResponseIterator crashes on non-string stream chunks 2026-03-12 16:16:32 -07:00
baseten/chat
bedrock [Feat] - Ishaan main merge branch (#23596) 2026-03-14 09:40:00 -07:00
bedrock_mantle feat(provider): add Amazon Bedrock Mantle as a first-class provider 2026-03-05 00:03:40 -05:00
black_forest_labs fix(tests): update BFL image generation tests for new signature 2026-03-13 00:20:52 +00:00
bytez/chat
chat test(bedrock): add unit tests for region extraction from bedrock/{region}/{model} path 2026-03-02 11:06:27 +05:30
chatgpt test(chatgpt): restore gpt-5.2 codex transformation coverage 2026-03-05 17:00:49 -05:00
cohere
cometapi/chat
compactifai
custom_httpx [Release Fix] (#22411) 2026-02-28 09:46:35 -08:00
dashscope fix: remove list-to-str transformation from dashscope 2026-02-19 07:30:13 +00:00
databricks Address Greptile review: fix SDK auth fallback and remove unused imports 2026-02-18 15:57:50 +09:00
datarobot
deepgram
deepinfra
docker_model_runner
featherless_ai/chat fix(tests): use monkeypatch for env var isolation in featherless tests 2026-03-01 23:46:15 +01:00
fireworks_ai Reapply "feat: add model_cost aliases expansion support" 2026-03-12 13:36:57 -03:00
gemini fix(tests): stabilize 3 failing CI tests 2026-03-13 00:26:31 +00:00
github_copilot
heroku
hosted_vllm CircleCI test stability (#23055) 2026-03-07 15:19:39 -08:00
huggingface
jina_ai/embedding
lemonade
litellm_proxy/chat
llamafile/chat
lm_studio
manus
meta_llama
minimax
mistral merge: resolve conflicts between main and litellm_oss_staging_03_11_2026 2026-03-12 09:38:31 -03:00
moonshot fix: auto-fill reasoning_content for moonshot kimi reasoning models in multi-turn tool calling (#23580) 2026-03-13 22:48:45 -07:00
nebius
novita/chat
nscale/chat
oci/chat
ocr Add OCR guardrail_translation handler and support (#22145) 2026-02-28 17:39:36 -08:00
ollama fix(ollama): thread api_base to get_model_info + graceful fallback (#21970) 2026-02-23 21:00:37 -08:00
openai fix(tests): update TestGPT5ReasoningEffortPreservation for dict normalization 2026-03-14 00:13:16 +05:30
openai_like merge: resolve conflicts between main and litellm_oss_staging_03_11_2026 2026-03-12 09:38:31 -03:00
openrouter CircleCI test stability (#23055) 2026-03-07 15:19:39 -08:00
ovhcloud
perplexity merge: resolve conflicts between main and litellm_oss_staging_03_11_2026 2026-03-12 09:38:31 -03:00
pg_vector/vector_stores
publicai
ragflow/chat
recraft
runwayml
s3_vectors
sagemaker Reapply "feat: add model_cost aliases expansion support" 2026-03-12 13:36:57 -03:00
sambanova
sap fix(sap provider layer): enable response-format for anthropic models and improve compatibility for GPT models via LangChain (#22804) 2026-03-04 16:03:59 -08:00
snowflake merge: resolve conflicts between main and litellm_oss_staging_03_11_2026 2026-03-12 09:38:31 -03:00
stability
vercel_ai_gateway
vertex_ai PR #22867 added _remove_scope_from_cache_control for Bedrock and Azur… (#23183) 2026-03-13 22:41:25 -07:00
volcengine
voyage/rerank
wandb
watsonx Merge remote main and resolve conflicts 2026-03-09 15:34:50 -07:00
xai
zai
test_cache_control_and_reasoning.py
test_lifecycle_fix.py
test_oom_fixes.py