Commit graph

48367 commits

Author SHA1 Message Date
yucheng
8af770ca83 fix(mcp): point the Agent 365 sign-in challenge at the metadata for the route the client used
The connect-time 401 always named /.well-known/oauth-protected-resource/mcp/{server}, so a client on the
/{server}/mcp URL fetched a document whose resource was a different URL and RFC 9728 strict clients
(newer Claude Code) stopped before opening the browser. Reuse get_passthrough_resource_metadata_url so
the challenge is absolute and matches the inbound path, on both the connect challenge and OBO preflight

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-11 22:35:05 +00:00
yucheng
de2f6b2f85 fix(mcp): challenge Agent 365 gated connects that carry only a LiteLLM key in Authorization
Some checks failed
LiteLLM Rust / rust-lint (push) Waiting to run
LiteLLM Rust / rust-test (push) Waiting to run
Terraform Modules / fmt, validate, test (aws) (push) Has been cancelled
Terraform Modules / fmt, validate, test (gcp) (push) Has been cancelled
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled
A LiteLLM virtual key in the Authorization header admits the caller but is not an Entra assertion the guardrail can exchange, so the connect-time RFC 9728 challenge now fires unless the bearer is a compact JWS. The guardrail parses the inbound bearer with the same predicate

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-11 09:02:28 +00:00
yucheng
dfbca29e5e Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_agent365_mcp_guardrail 2026-09-11 07:55:30 +00:00
yucheng
df739bdd9e fix(mcp): hand pre-call hooks the metadata of the registered tool that actually runs
Building the guardrail's tool metadata from the local registry entry that
dispatch resolved, instead of re-deriving it from the tool name, keeps an
OpenAPI operation whose name starts with its own server prefix from being
reported with the shorter operation's description and schema. The registry
branch in get_listed_tool is gone with it, and the test doubles for the
local registry now carry a string description and dict schema like the real
entries do

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-11 07:54:36 +00:00
joshua-berri
9a715df212
Merge pull request #40665 from BerriAI/litellm_fix_openapi_mcp_health_4896
fix(mcp): check OpenAPI specifications without native MCP handshakes
2026-09-10 22:02:45 -07:00
yucheng
6c865d1413 fix(mcp): resolve OpenAPI tool metadata from the local registry before any tools/list
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-11 04:34:56 +00:00
yucheng
0f7105f25e fix(mcp): hand listed tool metadata to pre-call hooks on the local registry path
OpenAPI-generated and legacy local-registry tools dispatch through execute_mcp_tool's
local branch, which called pre_call_tool_check without the cached MCPTool. Agent 365
therefore received bare {"name"} payloads for those tools while managed-server tools
carried description and inputSchema. Both local call sites now pass get_listed_tool

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-11 03:43:33 +00:00
Joshua Valluru
ca03c889c9 fix(mcp): avoid caching cancelled OpenAPI health probes 2026-09-10 20:26:53 -07:00
joshua-berri
acb9086f29
Merge pull request #40664 from BerriAI/litellm_fix_mcp_vscode_dcr_7449
fix(mcp): accept VS Code OAuth registration callbacks
2026-09-10 20:17:46 -07:00
yucheng
886220375f fix(guardrails): agent 365 sign-in for scopeless servers and gateway credential errors
Scopeless Agent 365 gated servers now advertise api://<client_id>/access_as_user instead of
staying silent, so a client can still sign in. Entra rejecting the gateway's own credentials
(invalid_client, unauthorized_client, invalid_scope, invalid_resource) follows unreachable_fallback
rather than telling the caller to sign in again with a 401

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-11 03:15:59 +00:00
Joshua Valluru
da1dfcdb24 refactor(mcp): reuse the shared HTTP handler for bounded probes 2026-09-10 19:59:07 -07:00
yucheng
803f8a69f0 test(mcp): assert the no-challenge outcome and register openapi tools through the registry api
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-11 02:56:34 +00:00
Mateo Wang
ff4b558243
Merge pull request #40624 from BerriAI/litellm_redis_breaker_open_silent_miss
fix(caching): keep an open Redis circuit breaker open and quiet on the sync read and spend counter paths
2026-09-10 19:55:22 -07:00
yucheng
02233a2df3 refactor(mcp): build agent 365 protected resource metadata immutably to satisfy the type discipline gate
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-11 02:49:13 +00:00
Joshua Valluru
576c1bc5d6 fix(mcp): bound and coalesce OpenAPI health probes 2026-09-10 19:45:44 -07:00
mateo-berri
25ed0abfc9 chore(ui): regenerate schema.d.ts after merging the base 2026-09-10 19:42:27 -07:00
mateo-berri
fdd423128e Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_redis_breaker_open_silent_miss 2026-09-10 19:40:52 -07:00
Joshua Valluru
5735587133 chore(ui): sync API descriptions with the current default branch 2026-09-10 19:30:10 -07:00
Joshua Valluru
86c5cd736b chore: sync API descriptions from the updated base branch 2026-09-10 19:29:19 -07:00
Joshua Valluru
fc95d22367 fix(mcp): accept VS Code OAuth registration callbacks 2026-09-10 19:28:40 -07:00
yucheng
d5b8effa99 fix(mcp): skip prefix lookup when a server has no listed tools
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-11 02:27:19 +00:00
mateo-berri
2fc520329f fix(router): keep the budget push off the request callback path
The provider budget push runs inside the request success callback, so
awaiting the Redis pipeline there made every request wait for the round
trip. Hand it back to a task whose failure is logged through the breaker
aware logger, so an open breaker stays a debug line and a real Redis error
is one error line instead of an unretrieved task traceback
2026-09-10 19:26:28 -07:00
tin-berri
7419a536ad
fix(auto-router): omit Claude Code system text from classifier (#40655)
Co-authored-by: Claude Code <noreply@anthropic.com>
2026-09-10 19:18:25 -07:00
Joshua Valluru
8c82c325ac fix(mcp): check OpenAPI specifications without native MCP handshakes 2026-09-10 19:18:19 -07:00
mateo-berri
0ffe6512de fix(router): keep the routing and budget sync loops quiet while the Redis breaker is open 2026-09-10 19:15:40 -07:00
yucheng
e9c654869f Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_agent365_mcp_guardrail 2026-09-11 02:14:35 +00:00
ryan-crabbe-berri
dca71e214b
Merge pull request #40647 from BerriAI/litellm_team_keys_table_entity_links
feat(ui): link the entity cells on the team detail page's keys table
2026-09-10 19:09:29 -07:00
yucheng
faa430c6c1 feat(mcp): challenge Agent 365 gated MCP servers with the Entra RFC 9728 metadata
When an Agent 365 guardrail applies to an MCP server that advertises scopes and no bearer arrives,
reuse the MCP OBO raise_token_exchange_challenge so the 401 and WWW-Authenticate header leave at the
transport layer. The protected-resource metadata for that server names the guardrail's Entra v2
issuer and the server's scopes, so Claude Code and other MCP clients run browser SSO and attach the
bearer themselves instead of the user pasting a token into the client config.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-11 02:08:09 +00:00
yucheng
35a1d017dc feat(guardrails): send MCP tool metadata to Agent 365 and treat unevaluated Defender verdicts as unavailable
Carry the listed tool's description and inputSchema from MCPServerManager through the pre-call and
during-call hook request objects into the Agent 365 evaluate payload, omitting them when the tool was
never listed. An allowed verdict whose defender.status is not Evaluated (Skipped, FailedOpen, missing)
now follows the unreachable_fallback policy instead of counting as a scanned allow. The conversationId
prefers the proxy-owned litellm_call_id over caller-controlled mcp-session-id headers.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-11 02:08:01 +00:00
devin-ai-integration[bot]
9c7ac0a6ea
fix(helm): give the collector sidecar the pod PgBouncer env when database.connectionPool is enabled (#40660)
The componentized chart rendered litellm.connectionPoolEnv into the gateway
container only, so with database.connectionPool.enabled and
gateway.collector.enabled the collector's Prisma client opened its own pool
straight to Postgres instead of going through the pod-local PgBouncer.

Render the same include in the collector container, drop the gateway.extraEnv
workaround from the collector test, and add enabled/disabled regression
assertions for the collector in both helm charts and the terraform aws and gcp
modules, which already pass the pool env to their collector containers. The
module READMEs note the IAM token-auth exception, where the collector keeps a
direct connection by design.

Co-authored-by: yassin <yassin@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-11 02:07:04 +00:00
mateo-berri
01c6b50564 fix(caching): let a Redis breaker success count only for the state that admitted the call 2026-09-10 18:57:24 -07:00
yuneng-jiang
a13c278d09
Merge pull request #40630 from BerriAI/litellm_/release-version-bump-ecd68e
chore: bump litellm-proxy-extras 0.4.95 -> 0.4.96
2026-09-10 18:48:54 -07:00
ryan-crabbe-berri
06b259e092 fix(ui): name the popover copy buttons after the field they copy
The shared user popover copied alias, email and ID through three copy
buttons that all announced themselves as "Copy ID", so a screen reader
could not tell them apart. IdCell now takes the label, defaulting to the
old text everywhere else.

Also drops the closest("tr") the new link tests used, which put the
testing-library/no-node-access budget over its ceiling, and asserts the
sentinel row leaves User Email and the admin badge unlinked too.

Claude-Session: https://claude.ai/code/session_01NfwfQhamRNnSqgXMUjf3h4
2026-09-10 18:40:05 -07:00
ryan-crabbe-berri
56e2d8846d feat(ui): link the entity cells on the team detail page's keys table
The team detail page's Virtual Keys table showed Organization ID, User
Email, User ID and Created By as dead text, so getting from a key to the
org or user behind it meant copying an id and searching for it.

Those four cells now render as links, reusing the sentinel-aware href
helpers, so default_user_id and the litellm-dashboard team stay plain
text instead of pointing at pages that do not exist.

The Created By cell was a verbatim copy of the Virtual Keys page's user
popover, so that moved into the shared table_cells kit and both tables
now use the one implementation.

Claude-Session: https://claude.ai/code/session_01NfwfQhamRNnSqgXMUjf3h4
2026-09-10 18:38:31 -07:00
devin-ai-integration[bot]
880ccc76a5
fix(streaming): keep admitted mock streams alive with empty stream_options and honor zero prompt counts (#40650)
* fix(streaming): keep usage-only chunks from crashing streams with empty stream_options

The usage-only chunk branch in CustomStreamWrapper.chunk_creator indexed stream_options["include_usage"] directly, so a caller passing stream_options={} hit a KeyError that surfaced as MidStreamFallbackError. Streaming mock_response with an admission input_tokens count (#40637) now always emits such a chunk, which made the crash reachable. Reuse the send_stream_usage policy computed at init instead. Also annotate the #40637 test bindings with Final.

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

* fix(streaming): report admitted zero prompt tokens instead of recounting in mock streams

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-10 18:37:39 -07:00
yuneng-jiang
ff834facc8
Merge branch 'litellm_internal_staging' into litellm_/release-version-bump-ecd68e 2026-09-10 18:37:33 -07:00
mateo-berri
dcdd884352 fix(caching): let only the recovery probe close a half-open Redis breaker
A call admitted before the breaker opened could finish while the breaker was
HALF_OPEN and close it before the designated probe reported, so Redis traffic
resumed on a stale answer. The admission now records whether the call is the
probe and only the probe's success closes a half-open breaker.

The cron job lock manager also logged an error every cycle the open breaker
refused its Redis call, one line per job per pod. That refusal is now a debug
line like every other guarded call, while real Redis errors still log at error
2026-09-10 18:36:19 -07:00
yuneng-jiang
41b0deb627
Merge pull request #40643 from BerriAI/litellm_fix_optional_logging_assertions
test: respect optional logging payload fields
2026-09-10 18:27:51 -07:00
ryan-crabbe-berri
b1ba92ab0f
Merge pull request #40646 from BerriAI/litellm_key_table_entity_links
feat(ui): link the Team, Organization, User and Created By cells on the Virtual Keys page
2026-09-10 18:27:12 -07:00
mateo-berri
7169ddaef6 fix(router): treat a breaker-refused Redis read as a miss in the health state cache
The sync Redis read now raises while the circuit breaker is open, and the
health state merge caught that as a generic error, skipping the local write
and logging an error on every background health check cycle. Read the shared
snapshot through a helper that treats the refused read as a miss so the merge
falls back to the pod-local copy the way a swallowed connection error already did
2026-09-10 18:16:59 -07:00
Mateo Wang
4fbe2276a1
fix(logging): finish response metadata before the sync logging thread reads it (#39869)
* fix(logging): finish response metadata before the sync logging thread reads it

The async and sync client wrappers handed the response to the threaded success handler before computing its cost, call id, and api_base, so that thread inserted into the same metadata dict the request coroutine was still iterating and a finished chat completion turned into a 500 (dictionary changed size during iteration). Metadata is now finalized first, and the merge and header copies snapshot their dicts before iterating.

* fix(logging): snapshot metadata with a dict copy and drop redundant comment

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

* fix(logging): copy metadata via dict.copy and dedupe Final import

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-10 18:15:24 -07:00
Yuneng Jiang
d1a1cda144
test: respect optional logging payload fields 2026-09-10 18:07:12 -07:00
ryan-crabbe-berri
5ea2f96982 feat(ui): link the Organization cell on the Virtual Keys page too
Same treatment as User, Team and Created By in the previous commit: the
Organization column rendered the alias as dead text, so it now goes through
IdentityCell with an orgDetailHref.

Claude-Session: https://claude.ai/code/session_01NfwfQhamRNnSqgXMUjf3h4
2026-09-10 17:59:22 -07:00
yuneng-jiang
2f46425732
Merge pull request #40638 from BerriAI/litellm_fix_stale_completion_fixtures
test: fix stale completion response fixtures
2026-09-10 17:50:07 -07:00
mateo-berri
e9c388d799 fix(caching): keep an open Redis circuit breaker quiet on the sync read and spend counter paths
The sync get path was unguarded, logged with a stray format argument, and never fed the
breaker. The sync batch read swallowed the breaker's refusal as an ERROR plus a service
failure event per call, so DualCache dropped its in-memory hits and left batch reservations
behind. record_success closed an OPEN breaker on stale in-flight successes, skipping the
recovery timeout and the half-open probe. The spend counter pipeline re-raised the refusal
into the cost callback, which logged an ERROR and fired the failed-tracking alert per request.
2026-09-10 17:49:20 -07:00
devin-ai-integration[bot]
985ac6b6a5
fix(rate_limiter): skip non-Latin-1 x-litellm-priority header on /v1/messages (#40636)
A team or key priority that is not Latin-1 encodable (for example CJK text) was
attached as a response header by the dynamic rate limiter v3 post-call hook, and
Starlette then raised UnicodeEncodeError while writing headers, turning a
successful /v1/messages call into HTTP 500. The header is now omitted for such
values while x-litellm-rate-limiter-version and the v3 rate limit headers are
still attached.

Co-authored-by: yucheng <yucheng@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-10 17:48:46 -07:00
devin-ai-integration[bot]
c7a41c35d5
perf(mock): emit admission-time usage chunk on streaming mock_response (#40637)
* perf(mock): emit admission-time usage chunk on streaming mock_response

Streaming mock_response chunks carried no usage, so the chunk builder re-tokenized the whole prompt in Python after the stream ended even when budget reservation had already counted it at admission. The mock streaming generators now yield a final usage-only chunk carrying the admission prompt count (same completion count as the non-streaming path). Without an admission count the old tokenizer fallback stays.

* fix(mock): type the mock stream generators and keep the usage chunk on the content stream id

Review follow-up: the usage-only chunk was built with a fresh id, so CustomStreamWrapper switched response_id for the finish-reason and usage chunks. It now copies the content stream id. The generators also get full parameter and return annotations.

---------

Co-authored-by: yassin <yassin@berri.ai>
2026-09-11 00:48:25 +00:00
mateo-berri
68d3016a11 Merge branch 'litellm_internal_staging' into litellm_redis_breaker_open_silent_miss
Take the staging tree outright. #40620 already landed the typed
RedisCircuitBreakerOpenError, DEBUG-level refusal logging at every
DualCache, Cache, limiter, and router catch site, and sync timeout
classification, so the overlapping parts of this branch are superseded.
The pieces that are still missing on staging are rebuilt on top in the
next commit
2026-09-10 17:34:17 -07:00
ryan-crabbe-berri
8a4fae0e17
Merge pull request #40639 from BerriAI/litellm_enduser_budget_reset_bind_limit
fix(reset_budget_job): reset end users by budget link, not by user id
2026-09-10 17:31:25 -07:00
Yuneng Jiang
1f7c4d6784
test: fix stale completion response fixtures 2026-09-10 17:18:56 -07:00