Commit graph

49820 commits

Author SHA1 Message Date
Tin Chi Lo
398300c4e7 fix(router): honor team and key provider weights 2026-09-14 23:31:52 -07:00
Mateo Wang
b52de1675a
Merge pull request #40994 from BerriAI/litellm_sdk_exception_body_headers
fix(sdk): keep body and proxy headers on BadRequestError mapped from a litellm_proxy 400
2026-09-14 23:27:29 -07:00
mateo-berri
2bf44ed354 fix(guardrails): reject tool_use rewrites that are not JSON objects 2026-09-14 23:18:47 -07:00
IToSSc
8607c49ea1 feat: add aihubmix provider pricing entries
Add 72 model price entries for the aihubmix openai_like provider so
cost tracking and budgets work for aihubmix/* model calls. The
provider is already registered in llms/openai_like/providers.json
but model_prices_and_context_window.json had zero entries for it.

The Anthropic-family entries (claude-fable-5, claude-haiku-4-5,
claude-opus-4-8, claude-opus-5, claude-sonnet-5) carry the same
supports_adaptive_thinking, thinking_always_on,
supports_sampling_params, and prompt_cache_min_tokens flags already
used by this repo's other Anthropic re-exports (azure_ai, databricks,
openrouter, and so on) for the same underlying models, since those
flags gate request shapes the provider otherwise rejects with a 400.

TASK-2BK38Y
2026-09-15 14:16:20 +08:00
mateo-berri
aaf924693a fix(router): count num_retries_per_request across fallback hops
num_retries_per_request has always capped the retries of one request with its fallback hops included. #40930 started reading the per-hop attempted_retries counter instead, and every fallback hop restarts that counter at zero, so a request could spend a fresh retry budget on each hop and the legacy fallback cap test started seeing the hop run.

Router.log_retry now also keeps request_retry_count on the request metadata, incremented on every retry and fallback hop and never truncated the way previous_models is, and max_retries_per_request_hit reads that count. The flat retry records, the litellm_metadata coverage and caps above four from #40930 stay as they are, and the legacy test goes back to its previous_models == 0 assertion.
2026-09-14 23:13:50 -07:00
Mateo Wang
c93708b2a5
Merge pull request #40228 from AaronHowell/litellm_fix_responses_credentials_affinity
fix(responses): preserve provider affinity
2026-09-14 23:09:55 -07:00
mateo-berri
9fb94ea761 fix(exceptions): keep repeated litellm_proxy response headers on the rebuilt response
httpx.Headers.items() comma-joins repeated header names, so the rebuilt
response iterates multi_items() and keeps every value, matching what the
raw openai client exposes on e.response.headers
2026-09-14 22:59:40 -07:00
mateo-berri
e3152c011d fix(responses): classify streamed tool calls on the chat name and strip guardrail edits around the grammar block
The streaming bridge restored the namespace before deciding whether a tool call was a custom tool, so a namespaced function sharing a short name with a nested custom tool streamed back as a custom_tool_call. Classify on the raw chat tool name first, the way the non-streaming path already does.

The guardrail merge only stripped the namespace prefix and grammar suffix from the ends of the edited description, so a guardrail appending text after the grammar block left the block in the member description and the chat conversion appended it a second time. Strip the first occurrence of each instead.
2026-09-14 22:58:25 -07:00
Yuneng Jiang
7a7770db0d
test(e2e): verify streamed answers and tool continuation 2026-09-14 22:46:55 -07:00
mateo-berri
62b2b36ce9 test(proxy): drop the reformat-only diff of the request processing tests
The proxy edge test file no longer carries any test of this change, and
the remaining diff was the scoped format gate reflowing the whole file to
the 120 limit, so it goes back to the merge base bytes
2026-09-14 22:39:19 -07:00
yucheng-berri
91588221cd
Merge pull request #39050 from BerriAI/litellm_lit6314_guardrail_metadata_transfer
fix(guardrails): record not_run evaluation when scoping leaves nothing to scan
2026-09-14 22:31:16 -07:00
mateo-berri
6764ab2673 test(router): assert num_retries_per_request as a per-group cap that resets per fallback hop
#40930 (LIT-7505) changed num_retries_per_request from a request-wide
cap to a per-model-group cap that resets on every fallback hop, and its
own comment in litellm/__init__.py names that contract. The legacy
test_async_fallbacks_max_retries_per_request still asserted the old
request-wide reading (previous_models == 0), so the CircleCI router
suite has been red on main since that merge for every run-ci PR.

The test now reads the flat RetryAttemptRecord entries the fallback
call carries and asserts the new contract directly: every record is
from the first group, the retry at attempted_retries 0 is the real
AuthenticationError, and each later attempt was refused with
"Max retries per request hit!".
2026-09-14 22:29:32 -07:00
Mateo Wang
a78b24c195
Merge pull request #41172 from BerriAI/litellm_azure_spend_log_zero_cost
fix(proxy): log the provider usage on deferred /v1/messages calls and price cache writes without a creation rate
2026-09-14 22:26:22 -07:00
Yuneng Jiang
80d804d6f9
test(spend): preserve multi-day coverage and immutable assertions 2026-09-14 22:26:20 -07:00
Yujong Lee
bc031e0f30 build(rust-bridge): drop redundant maturin include for _native.pyi
maturin already packages non-gitignored files under the Python source
directory of a mixed project, and the built wheel contains
litellm/rust_bridge/_native.pyi without the explicit entry

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-15 05:26:07 +00:00
mateo-berri
1b594fc935 fix(guardrails): scan empty top-level system text blocks too
The hoisted structured row keeps every text block of the top-level system
prompt, empty ones included, while the scanned texts dropped the empty ones.
Guardrails that count one text per slot then came back with more texts than
the handler could place, so their rewrite was rejected. User text blocks were
already scanned empty or not; the system prompt now matches.
2026-09-14 22:24:03 -07:00
mateo-berri
6a635cbb64 fix(sdk): carry a litellm_proxy error's headers on e.response, not e.headers
A mapped litellm_proxy exception now attaches an httpx.Response that
carries the proxy's response headers whenever the handler attached a
header-less synthetic one, on every status branch and on the relay
path. BadRequestError keeps its base-class contract: .headers stays the
proxy-supplied channel, so the proxy edge keeps forwarding an upstream
proxy's headers under the llm_provider- prefix and the date and server
edge change is no longer needed.
2026-09-14 22:22:26 -07:00
yucheng
fe0fb97fd2 fix(guardrails): record not_run when a skipped role mixes text and images
Only image-only unscoped content stays unrecorded; text or tool content
removed by scoping is recorded as not_run even when an image sits beside it.
Also keeps the type-discipline budget flat by returning the reason from the
helper and annotating the accumulator lists _extract_inputs requires.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-15 05:20:56 +00:00
mateo-berri
04410967ff Merge remote-tracking branch 'origin/main' into litellm_anthropic_guardrail_system_and_tool_use
main's test_one_text_per_row_over_a_system_prompt_is_rejected_by_name assumed the
top-level system prompt stays out of the scanned texts. This branch scans it, so one
text per structured row now lines up and the rewrite is applied; the test asserts that,
and a multi-block system prompt keeps the length-guard rejection covered.
2026-09-14 22:19:18 -07:00
yucheng
714b113c5f fix(guardrails): leave scoped-out image-only input unrecorded and split the not_run helper
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-15 05:10:32 +00:00
yucheng
9acdebf563 chore: merge origin/main into litellm_lit6314_guardrail_metadata_transfer
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-15 05:03:31 +00:00
mateo-berri
19dc66a48c fix(anthropic): add the per-turn-control beta when a message carries output_config 2026-09-14 22:01:47 -07:00
Mateo Wang
c16c172a65
Merge pull request #40939 from BerriAI/litellm_responses_per_message_guardrail_rewrite
fix(guardrails): write per-message guardrail rewrites back onto Responses input items
2026-09-14 21:57:29 -07:00
mateo-berri
d7a2bdd441 test(cost): type the cache rate cases of the base cost test 2026-09-14 21:56:23 -07:00
Yuneng Jiang
7e3d7178b4
test(spend): reconcile concurrent requests and daily activity 2026-09-14 21:52:01 -07:00
mateo-berri
8573241c49 fix(cost): resolve a missing 1h cache write rate after off-peak pricing
The one-hour cache write fallback now takes the applied cache write rate, so an off-peak write price carries into it instead of the input rate

The cost estimate test for a cost-map model without cache prices now expects writes at the input rate, which is what the proxy bills

The recording logger in the deferred guardrail test types its callback parameters
2026-09-14 21:46:33 -07:00
mateo-berri
f4f1e2eace refactor(sdk): move the None sentinel to constants and freeze the init kwargs filter 2026-09-14 21:46:22 -07:00
mateo-berri
31b34f7767 test(guardrails): type the Anthropic write-back test helper 2026-09-14 21:46:02 -07:00
Tin Chi Lo
bebc76316c fix(cli): label savings cost bars with the auto-router name 2026-09-14 21:42:57 -07:00
yassin
f808c6899f fix(router): bind per-request routing_strategy override selectors to the request's callbacks
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-15 04:42:25 +00:00
Yujong Lee
c7c71b95ad fix(rust-bridge): narrow OCR input_sources values to the native InputSource variants
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-15 04:39:28 +00:00
mateo-berri
f8c2539ba7 Merge remote-tracking branch 'origin/main' into litellm_azure_spend_log_zero_cost 2026-09-14 21:37:19 -07:00
mateo-berri
1111658e16 fix(bedrock): grant the AgentCore for-user invoke action in the web identity session policy
The chat and A2A AgentCore handlers send X-Amzn-Bedrock-AgentCore-Runtime-User-Id
when runtimeUserId is set, and AWS requires bedrock-agentcore:InvokeAgentRuntimeForUser
alongside InvokeAgentRuntime on that call, so the ceiling now carries both. The role
identity policy still decides whether a given role may use it

The invalid-token test now uses a neutral example audience
2026-09-14 21:31:45 -07:00
yuneng-jiang
b4cff58be7
Merge pull request #41181 from BerriAI/litellm_pin_ci_pricing
fix(ci): test checked-out model pricing in unit jobs
2026-09-14 21:31:34 -07:00
yuneng-jiang
26a13132f8
Merge pull request #41149 from BerriAI/litellm_strict_provider_identity
test: add strict stateless provider replay identity
2026-09-14 21:31:25 -07:00
mateo-berri
e01d97ea08 fix(guardrails): read Prompt Security modified rows with the slot count's own predicate
A chat row whose content carried an empty text part counted two slots in the
chat completions handler while Prompt Security read one text out of the
modified row, so the structured rewrite was dropped and the request got the
named rejection. One shared helper now lists a row's slot texts and both the
slot count and the modified-row reader use it.
2026-09-14 21:31:22 -07:00
mateo-berri
ae90f1a458 fix(guardrails): type the request payload handed to the Anthropic write-back 2026-09-14 21:28:47 -07:00
mateo-berri
879fcd847f Merge remote-tracking branch 'origin/main' into litellm_sdk_exception_body_headers_do0914 2026-09-14 21:28:23 -07:00
Yujong Lee
c827344840 fix(rust-bridge): tighten _native stub for OCR input_sources and websocket construction
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-15 04:23:45 +00:00
jesus
71186e4ec1 merge: main into litellm_headroom_protect_cached_prefix
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-15 04:12:28 +00:00
Yuneng Jiang
6969bd9c54
ci: run replay harness on every admitted CircleCI pipeline 2026-09-14 21:12:16 -07:00
Yuneng Jiang
16fb44f23a
ci: run provider replay harness in CircleCI 2026-09-14 21:03:58 -07:00
Mateo Wang
94f08636c7
Merge pull request #40315 from rad-p44/fix/headroom-protect-cache-control-rows
fix(headroom): protect cache_control-marked rows anywhere in history
2026-09-14 21:03:16 -07:00
Yuneng Jiang
a1d216b7d7
fix(ci): test checked-out model pricing in unit jobs 2026-09-14 21:00:00 -07:00
Yujong Lee
ce7c4433ee build(rust-bridge): add typed _native stub and validate it with mypy.stubtest
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-15 03:54:16 +00:00
Mateo Wang
2bdafa1206
Merge branch 'main' into fix/headroom-protect-cache-control-rows 2026-09-14 20:53:07 -07:00
yuneng-jiang
9d7f2aad04
Merge branch 'main' into litellm_strict_provider_identity 2026-09-14 20:43:55 -07:00
yuneng-jiang
15bd8b0e4a
Merge pull request #40892 from BerriAI/litellm_jwt_management_callers
test: bind management E2E callers and isolate JWT actors
2026-09-14 20:30:52 -07:00
kerry-berri
03a4c806c4
Merge pull request #41157 from BerriAI/litellm_gemini_embedding_2_per_token_billing
fix(cost): bill gemini-embedding-2 per token and stop double charging audio
2026-09-14 19:49:11 -07:00
Devin AI
e668a31384 fix(health): keep realtime credential hydration immutable
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-15 02:43:48 +00:00