Commit graph

46478 commits

Author SHA1 Message Date
mateo-berri
425c8d37fc fix(containers): page upstream until a non-admin container list fills its limit
Forwarding limit to OpenAI made the ownership filter cut the page down after
the fact, so a key that owned an older container got an empty first page and
its cursor never moved. Non-admin lists now walk upstream pages of 100 until
they have enough owned containers (or five pages), trim to the requested
limit, and report first_id, last_id and has_more off what the caller keeps.

Also assigns tests/test_litellm/proxy/container_endpoints to a CI shard.
2026-09-02 21:26:34 -07:00
mateo-berri
872e115295 fix(containers): pass upstream error status through and forward list pagination params
The container retrieve, list, delete, create and file routes validated the
provider's error body against the success model, so a deleted or unknown
container and a rejected API key surfaced as 500 pydantic errors instead of
the upstream 404 or 401. The handlers now raise the provider error class with
the upstream status and message before transforming the response.

GET /v1/containers dropped after, limit and order before calling the
provider, and GET /v1/containers/{id}/files dropped the same three, so
paginated list calls ignored their pagination arguments. Both routes now
forward their declared query params.
2026-09-02 18:46:00 -07:00
tin-berri
993766be0e
feat(proxy): serve the auto-router preset catalog at runtime (#39412)
The dashboard's template picker imported autorouter_presets.json at build time, so every
catalog change needed a dashboard rebuild and artifacts refresh. The catalog now lives in
litellm/proxy/public_endpoints/ and GET /public/autorouter_presets serves it, fetching
litellm.autorouter_presets_url (GitHub raw on main, 1h in-process cache, bundled fallback)
so a merged catalog change propagates to running proxies like the model cost map does.
The dashboard fetches it at runtime via useAutoRouterPresets and keeps no local copy.

Resolves LIT-6764
2026-09-02 18:03:22 -07:00
tin-berri
ff1f21aea9
fix(ui): paginate request logs by session groups server-side (#39257)
* fix(ui): paginate request logs by session groups server-side

The logs table server-paginated raw spend logs and then collapsed
multi-call sessions client-side, so a page could render 3 rows while
the footer claimed 25 and sessions straddled pages. Adds an opt-in
group_by_session param to /spend/logs/ui that pages and counts one
representative row per session (DISTINCT ON, newest non-MCP call),
keeps the bounded count contract, enriches whole-session llm/agent
composition counts, and deletes the client-side collapse pipeline.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QxT89fiygmzz2ALcjpu7Ve

* feat(ui): add a 10 rows-per-page option and default request logs to it

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QxT89fiygmzz2ALcjpu7Ve

* fix(ui): key session aggregates per api key in the logs enrichment

Grouped pagination splits a reused session id into one row per api key,
but the enrichment still aggregated by session_id alone, so both rows
showed combined spend and counts. The aggregate query now groups by
(session_id, api_key), the count folds into it (the separate group_by
query is deleted), and each row reads its own key's totals.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QxT89fiygmzz2ALcjpu7Ve

* fix(ui): treat an empty api_key as a real session group value

The spend-log schema defaults api_key to an empty string; truthiness
guards in the enrichment treated it as missing, so keyless multi-call
sessions lost their count and spend. Only None means missing now.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QxT89fiygmzz2ALcjpu7Ve

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-02 17:54:17 -07:00
Mateo Wang
edbd4d1f98
Merge pull request #39428 from BerriAI/litellm_lite_login_prefill_code
feat(cli): pre-fill the SSO verification code in the browser when the proxy allows it
2026-09-02 17:48:39 -07:00
Yassin Kortam
44a6c659fb
fix(mcp): fence an outbound-token write against an overlapping invalidation (#35398)
get_or_compute single-flights concurrent misses under a per-key lock, but
invalidate() deletes outside it. A mint already awaiting the IdP when an
invalidation ran wrote its result into the slot afterwards, so a bearer minted
before the invalidation was served after it for its full TTL; the upstream-401
retry then re-presented the bearer the server had just rejected.

The cache now keeps a per-key generation beside the single-flight lock.
invalidate() bumps it and get_or_compute snapshots it inside the lock right
before minting, skipping the cache write when it no longer matches. The token
is still returned to the caller it was minted for, so only the caching is
fenced. Generation and lock share one object that a running mint binds to a
local, which pins the weak map's entry for exactly as long as a write can still
land; a generation held weakly on its own would be collected across the await
and the re-check would silently pass.
2026-09-02 17:45:58 -07:00
devin-ai-integration[bot]
c19d49d919
fix(responses): keep provider response headers in streaming logging callbacks (#38131)
* fix(responses): keep provider response headers in streaming logging callbacks

The responses streaming iterator captures the provider's HTTP response headers into
its own _hidden_params, but never puts them on the completed response, and the
model_validate(model_dump()) copy made for logging drops pydantic private attributes.
Success callbacks and StandardLoggingPayload.hidden_params.additional_headers therefore
saw an empty dict for streaming /v1/responses, so Azure's apim-request-id was unreadable
from the callback payload.

Restore the headers on the nested response of the logging copy, preferring any the
provider transform already set (the fake_stream path) and falling back to the ones the
iterator captured from the stream. Skipped when the copy fell back to the original event,
so a serialization failure never leaves logging-only state on the caller's object.

* fix: satisfy LIT002 mutable-collection gate in header restore

---------

Co-authored-by: Yucheng Zhu <yucheng@berri.ai>
2026-09-02 17:40:13 -07:00
devin-ai-integration[bot]
8cbaba8863
fix(mcp): gate the connect-time OBO pre-flight on the key's allowed servers (#39447)
The pre-flight token exchange resolved its target from the requested path, so a key not entitled to that server still drove an outbound exchange at the IdP and populated the credential cache before the later access check denied it. Resolve the target through the same allowed-server set the rest of the route uses and skip the exchange when the requested server is not in it.

Co-authored-by: yassin <yassin@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-02 17:39:36 -07:00
devin-ai-integration[bot]
8e3566d2f7
fix(guardrails): forward mode and streaming params to crowdstrike_aidr handler (#39317)
* fix(guardrails): forward mode and streaming params to crowdstrike_aidr handler

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(guardrails): drop stream_chunk_builder patch from crowdstrike cadence test

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(guardrails): type test params and cover unsupported crowdstrike mode rejection

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-02 17:38:43 -07:00
Yassin Kortam
7978b9f721
fix(proxy): stop leaking internal exception details to clients (#39380)
* fix(proxy): stop leaking internal exception details to clients

Public error responses could disclose internal details in two places.
A proxy-layer exception with no recognized provider status code (a bug
in a custom callback, a hook, or litellm's own code) forwarded its raw
str() text verbatim on a 5xx, including any embedded credential,
filesystem path, or internal hostname, or a full stack trace; the
same client-facing message now runs through a redaction layer built
on top of the credential redaction that already runs on log output,
so it also drops an embedded traceback and scrubs path-shaped and
hostname-shaped substrings. It intentionally never runs on server-side
logs, which must keep full detail for debugging.

exception_type(), litellm's core exception mapper, is shared by direct
SDK callers (litellm.completion()) and the proxy, and it deliberately
embeds a traceback into an unmapped exception's message as a debugging
aid for library users; a first pass at this fix stripped that
traceback inside exception_type() itself and broke that convention
(caught by tests asserting on the traceback frame). The traceback stays
in exception_type()'s own output; only the proxy's client-facing
response boundary (and the streaming response generator, which never
needs to embed one at all) strips it.

Full generic-message replacement for the unclassified-exception case
was tried first and reverted too: several routes deliberately raise a
bare exception as an informative, secret-free validation message (e.g.
the OCR endpoint's rejection of provider-native file IDs), and
replacing those wholesale broke that convention; targeted redaction
leaves them untouched.

Also stops the default uvicorn-based proxy from sending a Server
response header.

Resolves LIT-6747

* refactor(proxy): drop the unrelated error-message constant and trim redaction comments

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-02 17:32:00 -07:00
devin-ai-integration[bot]
5ad330f620
fix(http_handler): honor HTTP(S)_PROXY / NO_PROXY when force_ipv4 uses the httpx transport (#39443)
* fix(http_handler): honor HTTP(S)_PROXY / NO_PROXY when force_ipv4 uses the httpx transport

Passing an explicit transport to httpx.AsyncClient / httpx.Client disables its
automatic environment proxy mounts, so force_ipv4 on the httpx path sent every
LLM request direct and silently bypassed HTTPS_PROXY. Mount the same env-derived
proxy transports next to the IPv4-pinned direct transport in AsyncHTTPHandler,
HTTPHandler and the OpenAI async client factory.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(http_handler): carry the client's TLS verify and cert settings onto env proxy mounts

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: yassin <yassin@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-02 17:30:46 -07:00
yassin
8442fb2784 chore: merge litellm_internal_staging and resolve type-discipline-budget conflict
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-03 00:30:35 +00:00
Mateo Wang
e1a7af7e58
Merge pull request #39442 from BerriAI/litellm_e2e_ui_password_policy
test(e2e/ui): give the seeded users passwords that pass the default password policy
2026-09-02 17:29:54 -07:00
yujonglee
1e6a4d98a4
Merge pull request #38936 from BerriAI/litellm_fix_vector_store_request_embedding_resolution
fix(vector-store): resolve embedding credentials per request
2026-09-02 17:22:56 -07:00
Mateo Wang
708c396b90
Merge pull request #39366 from BerriAI/litellm_responses_guardrail_namespace_tools
fix(responses): keep namespace tools intact when a guardrail returns them unchanged
2026-09-02 17:19:21 -07:00
mateo-berri
62badd58fb merge: origin/litellm_internal_staging into litellm_lite_login_prefill_code 2026-09-02 17:06:35 -07:00
mateo-berri
2842e90836 Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_responses_guardrail_namespace_tools
# Conflicts:
#	type-discipline-budget.json
2026-09-02 17:06:33 -07:00
Mateo Wang
8c58b93572
Merge pull request #39239 from BerriAI/litellm_lit_6342_claude_subagent_router
fix(router): route Claude Code subagents through session router
2026-09-02 17:05:55 -07:00
mateo-berri
e641864e6f test(e2e/ui): give the seeded users passwords that pass the default password policy
The default password policy from #39381 (12+ chars with upper, lower, number, and special) makes globalSetup's POST /user/update with password "test" fail with a 400, so every role login in the UI e2e suite has been failing since that merge. Seed the roles, the noteam@test.local login, and the second-admin spec with policy-compliant passwords and update the scrypt hash in seed.sql to match.
2026-09-02 16:58:53 -07:00
devin-ai-integration[bot]
b0fe71010b
fix(ollama_chat): stamp finish_reason tool_calls when tool calls streamed before the done chunk (#39010)
* fix(ollama_chat): stamp finish_reason tool_calls when tool calls streamed before the done chunk

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ollama_chat): trim finish_reason override comment

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: mubashir1osmani <mubashir.osmani777@gmail.com>
2026-09-02 16:56:35 -07:00
Mateo Wang
d3929048f1
Merge pull request #39187 from BerriAI/litellm_fix_v2_resolver_migration_deadlock
fix: recover the v2 migration resolver from concurrent migrate deploy deadlocks
2026-09-02 16:54:03 -07:00
mateo-berri
293fa26e6c merge: origin/litellm_internal_staging into litellm_lite_login_prefill_code 2026-09-02 16:53:06 -07:00
mateo-berri
1df402b80d fix(vector-store): carry request metadata into the Router executor built from the router kwarg 2026-09-02 16:53:05 -07:00
tin-berri
632898b2a6
feat(router): add a hybrid classifier that defers near tier boundaries (#39403) 2026-09-02 23:51:43 +00:00
Mateo Wang
95b511bc19
Merge pull request #39362 from BerriAI/litellm_lit5443_mantle_chat_aws_creds
fix(bedrock_mantle): carry per-request AWS credentials into chat completions SigV4 signing
2026-09-02 16:48:16 -07:00
Mateo Wang
4ffe536a69
Merge pull request #39355 from BerriAI/litellm_fix_messages_passthrough_cache_control_ttl
fix(messages): drop cache_control ttl on non-Anthropic /v1/messages passthrough
2026-09-02 16:47:26 -07:00
Mateo Wang
cd9ed8bad5
Merge pull request #39363 from BerriAI/litellm_hosted_vllm_rerank_truncate_params
fix(hosted_vllm): forward truncate_prompt_tokens on rerank requests
2026-09-02 16:47:20 -07:00
Mateo Wang
c1a26f36ee
Merge pull request #38791 from BerriAI/litellm_fix_mcp_oauth_tool_fetch_auth
fix(mcp): cap tools preview and test-connection at the listing timeout and name the unreachable upstream
2026-09-02 16:47:10 -07:00
Mateo Wang
c9562e1dd9
Merge pull request #39091 from BerriAI/litellm_techdebt_20260901
chore(techdebt): clear fresh debt from the 2026-08-31 and 2026-09-01 windows
2026-09-02 16:46:52 -07:00
Mateo Wang
ff71808671
Merge pull request #35967 from BerriAI/litellm_bedrock_strip_client_metadata
fix(bedrock): strip client_metadata from converse additionalModelRequestFields
2026-09-02 16:46:48 -07:00
Mateo Wang
4286be8d5b
Merge pull request #39364 from BerriAI/litellm_fix_bedrock_mantle_messages_env_api_base
fix(bedrock): honor BEDROCK_MANTLE_API_BASE on bedrock/mantle messages and chat URLs
2026-09-02 16:46:44 -07:00
mateo-berri
3f9e44f839 Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_responses_guardrail_namespace_tools
# Conflicts:
#	type-discipline-budget.json
2026-09-02 16:45:49 -07:00
Yassin Kortam
c16c2cd6ee
fix(proxy): mark session/SSO/SAML cookies Secure behind a TLS-terminating reverse proxy (#39391)
* fix(proxy): mark session/SSO/SAML cookies Secure behind a TLS-terminating reverse proxy

litellm only sees a plain-HTTP hop when TLS terminates at a reverse proxy,
so cookie Secure attributes previously derived from (or defaulted without
regard to) the literal request scheme could be dropped in production. The
token session cookie set by every login path never carried Secure/HttpOnly/
SameSite at all.

Adds IPAddressUtils.is_request_https, a single trust-aware resolver used by
every cookie-setting call site: PROXY_BASE_URL, then X-Forwarded-Proto only
from a configured trusted proxy (general_settings.use_x_forwarded_for +
mcp_trusted_proxy_ranges), then the literal scheme. An unconfigured or
untrusted caller cannot spoof the header to force Secure on.

Resolves LIT-6748

* fix(proxy): make the shared session-cookie helper public, type new test helpers

set_session_token_cookie is imported across modules (ui_sso.py ->
proxy_server.py), so the leading underscore was misleading and breached
basedpyright's reportPrivateUsage budget with zero headroom. Also adds
missing parameter/return type annotations to the new test helper functions
per repo convention.
2026-09-02 16:42:29 -07:00
mateo-berri
4ebac321a1 merge: origin/litellm_internal_staging into litellm_lite_login_prefill_code 2026-09-02 16:38:30 -07:00
Mateo Wang
22cc97fe0a
Merge pull request #39159 from BerriAI/litellm_bedrock_converse_legacy_thinking_adaptive
fix(anthropic): upgrade legacy thinking to adaptive on adaptive-only Claude models for chat, Bedrock Converse, Invoke, Vertex AI, and Databricks
2026-09-02 16:35:03 -07:00
tin-berri
9aeeca4ce3
feat(router): add heuristic v2 complexity routing (#39276)
* feat(router): add trained heuristic complexity routing

* feat(router): expose heuristic v2 classifier

* style(router): format heuristic v2 predictor
2026-09-02 23:33:04 +00:00
mateo-berri
1636fdd3e6 Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_responses_guardrail_namespace_tools
# Conflicts:
#	basedpyright-code-budget.json
#	type-discipline-budget.json
2026-09-02 16:29:34 -07:00
yujonglee
082bea851e
Merge pull request #39334 from BerriAI/litellm_rust_opt_in_configuration
feat(python): unify Rust opt-in and bridge policy
2026-09-02 16:26:36 -07:00
yujonglee
34b45f3d79
refactor(python-bridge): declare sync and async routes once (#39333)
* refactor(rust): move audio transcription into core

* refactor(python-bridge): split non-streaming bridge modules

* fix(python-bridge): harden sync and async route boundaries

* refactor(python-bridge): declare sync and async routes once
2026-09-02 16:26:36 -07:00
yujonglee
62e318de8e
fix(python-bridge): harden sync and async route boundaries (#39332) 2026-09-02 16:26:35 -07:00
yujonglee
198906495f
refactor(python-bridge): split routes and add shared function tracing (#39031)
* refactor(python-bridge): split non-streaming bridge modules

* refactor(python-bridge): bring shared function tracing into route layer

* feat(dev): list Python route functions and call sites

* feat(dev): list Rust route functions and call sites

* docs(dev): record OCR parity gaps across Python and Rust

* feat(dev): list executed SDK calls with runtime tracing

* feat(dev): report Python vs Rust SDK pipeline steps in one CLI

* feat(dev): side-by-side pipeline step report in compare CLI

* fix(dev): drop invalid Final annotations in compare cell loop

* feat(dev): blue python-only and yellow rust-only steps in compare CLI

* feat(dev): vertical layout with section spacing in compare CLI

* fix(dev): validate SDK trace stages across sync and async routes

* refactor(rust): align SDK route call structure with Python

* refactor(python-bridge): share sync and async route call wrappers

* refactor(dev): split compare CLI into fixtures, runtime, and report modules

* fix(ci): run SDK trace tests and satisfy test lint
2026-09-02 16:26:35 -07:00
mateo-berri
63f5de12ae chore(techdebt): ratchet lint budgets to the merged tree 2026-09-02 16:25:58 -07:00
mateo-berri
683fc34044 fix(azure_ai): let the caller's output_config from extra_body win over the legacy thinking upgrade 2026-09-02 16:23:52 -07:00
mateo-berri
8c646a916c feat(cli): pre-fill the SSO verification code in the browser when the proxy allows it 2026-09-02 16:19:17 -07:00
moe-berri
f5721ff6f0 test(router): cover Claude session multi-hop fallbacks 2026-09-02 16:17:35 -07:00
mateo-berri
ddc2582374 fix(vector-store): build the Router executor from the router kwarg and gate the SDK fallback on explicit config 2026-09-02 16:15:20 -07:00
Mateo Wang
3c6b0705b2
Merge pull request #39420 from BerriAI/litellm_bedrock_kb_fake_router_kwarg
test(bedrock): accept the router kwarg in the knowledge base search fake
2026-09-02 16:13:47 -07:00
Yassin Kortam
bc2370f3fd
test(proxy): verify NO_DOCS/NO_REDOC/NO_OPENAPI restrict every doc surface (#39378)
* test(proxy): verify NO_DOCS/NO_REDOC/NO_OPENAPI gate every doc surface

Confirms /docs, /redoc and /openapi.json are reachable by default and
each 404 with no schema in the body when NO_DOCS/NO_REDOC/NO_OPENAPI are
set, and that disabling them does not affect other routes.

* test(proxy): pin the production docs_url construction to the real helpers

Addresses Greptile 4/5 feedback: the disabled-path tests built a fresh
FastAPI() app, which could miss drift in the actual
FastAPI(docs_url=..., ...) call in proxy_server.py. This pins that
exact call site against _get_docs_url/_get_redoc_url/_get_openapi_url.
2026-09-02 16:06:04 -07:00
mateo-berri
8e26d13fa0 test(bedrock): type the router parameter on the knowledge base search fake 2026-09-02 16:03:39 -07:00
moe-berri
1306a4505a fix(router): preserve bound router fallbacks for subagents 2026-09-02 16:01:15 -07:00