Commit graph

37495 commits

Author SHA1 Message Date
Ishaan Jaffer
2b5eb794fc
fix(mcp): set instructions=None in test_add_update_server_with_alias mock 2026-04-14 12:40:55 -07:00
ishaan-berri
0e43050a01
Merge pull request #25650 from BerriAI/litellm_dev_04_13_2026_p1
feat: add litellm.compress() — BM25-based prompt compression with ret…
2026-04-14 12:24:47 -07:00
Ishaan Jaffer
92a5ed4c3d
fix(mcp): set instructions=None in test_add_update_server_fallback_to_server_id mock 2026-04-14 12:15:54 -07:00
Tim
db94b4d55c
fix(cost-map): add us-south1 to vertex qwen3-235b-a22b-instruct-2507-maas (#25382) 2026-04-14 11:59:36 -07:00
Sameer Kankute
1a9a31e4a2
Merge pull request #25665 from BerriAI/litellm_oss_staging_04_13_2026_p1
litellm oss staging 04/13/2026
2026-04-14 23:50:08 +05:30
yuneng-jiang
25c444c8d5
Merge pull request #25686 from milan-berri/fix/key-update-cross-team-auth-check
fix(proxy): enforce team membership in team-scoped key management checks
2026-04-14 11:15:36 -07:00
Sameer Kankute
dec630b365
Fix mypy issues 2026-04-14 23:37:50 +05:30
LeVDuan
085e70cd3e
refactor: extract search tool conflict resolution into _resolve_search_tool_conflict method 2026-04-14 23:37:50 +05:30
LeVDuan
cacc3b326d
fix: skip dropping search tools when server-side tool invocations enabled (Gemini 3+) 2026-04-14 23:37:49 +05:30
LeVDuan
1e79ad69ab
docs: add comment explaining why non-search tools are preserved 2026-04-14 23:37:49 +05:30
LeVDuan
212b249e38
fix(vertex_ai): drop search tools when mixed with function declarations (#23337)
Vertex AI rejects requests containing both search tools (googleSearch,
enterpriseWebSearch, urlContext) and function declarations with error:
'Multiple tools are supported only when they are all search tools.'

When _merge_tools_from_deployment() combines deployment-level search
tools with user-request function tools (e.g. via MCP), the mixed tool
list causes a 400 error. This fix detects the conflict in _map_function()
and drops search tools, keeping function declarations.

Non-search tools like code_execution and computerUse are preserved.

Fixes #23337
2026-04-14 23:37:49 +05:30
Emerson Gomes
924418aeea
fix: prune expired in-memory cache heap entries (#25664) 2026-04-14 23:37:49 +05:30
Emerson Gomes
a302b53980
fix: drain datadog batches safely (#25663)
* fix: drain datadog batches safely

* fix: preserve datadog batches on 413

* fix: import time in datadog flush queue

* test: cover datadog batching edge cases

* fix: only stamp successful datadog flushes

* test: use sync mock for datadog payload builder
2026-04-14 23:37:49 +05:30
Jonas Neubert
e724e5e07d
add NO_OPENAPI env var to disable /openapi.json endpoint (#25547) 2026-04-14 23:37:49 +05:30
hatim-ez
17bfa420e4
fix(router): discard oldest entry when trimming latency list in lowest_latency strategy (#25548)
* fix(router): discard oldest entry when trimming latency list in lowest_latency strategy

The lowest_latency routing strategy keeps a rolling window of the most
recent latency and time-to-first-token measurements per deployment. When
the window is full, the strategy was discarding the *newest* value
instead of the oldest, because the trim used
`[: max_latency_list_size - 1]` (keeping indices 0..N-2) rather than
`[1:]` (dropping index 0 and keeping indices 1..N-1).

Since new values are appended at the end, the bug meant the most recent
measurement was always dropped once the list reached capacity. The
routing decisions then relied on stale data (including any early-spike
values that never aged out), and timeout penalties written via
`async_log_failure_event` were silently discarded as well.

Fix the slice in all five call sites (sync + async log_success_event for
both latency and time_to_first_token, and async_log_failure_event for
the timeout penalty) and add regression tests covering each path.

* test(router): cover async TTFT trim path in lowest_latency regression tests

Adds test_ttft_list_trimming_discards_oldest_entry_async, an async
counterpart to test_ttft_list_trimming_discards_oldest_entry that drives
async_log_success_event with a ModelResponse and completion_start_time so
the async time_to_first_token trim branch is actually exercised.

Previously no test touched that code path: the sync TTFT test used
log_success_event, and the async latency test passed a plain dict
response_obj without stream/completion_start_time, so TTFT was never
computed and the async trim was unreached. Verified load-bearing by
reverting only the async TTFT slice — the new test fails and all others
pass.

* format
2026-04-14 23:37:49 +05:30
Ashton Sidhu
6343148c95
Hiddenlayer Integration: Add V2 Integration (#22708)
* Serialize error message to a string; only scan last message

* Update litellm/proxy/guardrails/guardrail_hooks/hiddenlayer/hiddenlayer.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* Add v2 of hiddenlayer guardrail implementation

* Update litellm/proxy/guardrails/guardrail_hooks/hiddenlayer/hiddenlayer.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* Fix potential header issue

* linting

* Add image support

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-04-14 23:37:49 +05:30
Daan
1d45cfd1fc
fix(proxy) - #25506 Team members added before team_member_budget is configured have no budget enforcement (#25557)
* fix #25506

* address greptile review feedback

* [Test] UI - Models: Add E2E tests for Add Model flow

Add E2E tests covering:
- Test connection with bad credentials shows failure modal
- Adding a specific model and verifying it appears in All Models table
- Adding a wildcard route and verifying it appears in All Models table
- Verifying model dropdown shows provider-specific models (existing test updated)

Added data-testid attributes to UI components to support stable test selectors.

Tests verified passing 3/3 consecutive runs with zero flakiness.

* address greptile review feedback (greploop iteration 1)

Add cleanup helper to delete models created during tests, preventing
stale data accumulation across repeated test runs.

* fix CI: replace data-testid selectors with text/role-based selectors

The data-testid attributes added to React components are not present
in the CI-built UI output. Switch to using getByRole and getByText
selectors which work with the rendered DOM regardless of build cache.

* remove unnecessary cleanup helper

The database is freshly seeded on every test run via seed.sql,
so per-test cleanup is not needed.

---------

Co-authored-by: Yuneng Jiang <yuneng@berri.ai>
Co-authored-by: Krrish Dholakia <krrish+github@berri.ai>
2026-04-14 23:37:49 +05:30
Kris Yang
15245a5eb7
fix: emit input_json_delta for tool args bundled in first streaming chunk (#25533)
* fix: emit input_json_delta for tool args bundled in first streaming chunk

Some providers (xAI, Gemini) include tool_call function arguments in the
same streaming chunk as the function name/id. The AnthropicStreamWrapper
was discarding the trigger chunk entirely when starting a new content
block, which silently dropped the input_json_delta carrying tool
arguments. This caused tool_use blocks to arrive with empty input {}.

Now queue the processed_chunk after content_block_start when it carries
non-empty input_json_delta data. Backward compatible: providers that send
empty arguments in the first chunk (OpenAI-style) are unaffected since
the condition checks for truthy partial_json.

* test: add tests for input_json_delta emission on bundled tool args

Covers the fix for providers (xAI, Gemini) that bundle tool_call
arguments in the same streaming chunk as the function name/id.
Verifies the AnthropicStreamWrapper emits input_json_delta after
content_block_start, and that empty-arg chunks (OpenAI-style) are
unaffected.

* style: apply Black formatting to streaming_iterator.py

* fix: mirror input_json_delta fix to sync __next__ and add sync tests

* test: make no_extra_delta tests assert explicitly instead of passing silently
2026-04-14 23:37:49 +05:30
lucassz
dd93d2698b
fix(gemini): assign correct indices in batch embedding response (#25656)
### Background

The Gemini batchEmbedContents response handler hardcoded `index=0` for
every embedding in the response. Any consumer relying on the OpenAI-format
`index` field to match embeddings back to inputs would silently get wrong
associations.

### Changes

Use `enumerate` in `process_response` so each embedding gets its
positional index instead of 0.

### Test Plan

Added unit test asserting sequential indices and correct vector ordering
for a 3-element batch response.
2026-04-14 23:37:49 +05:30
yuneng-jiang
3f3760bdf4
Merge pull request #25324 from Lucas-Song-Dev/fix-ui-policy-attachment-delete
fix(ui): delete policy attachments via controlled modal
2026-04-14 11:05:29 -07:00
Ishaan Jaffer
8c505634bd
chore: sync uv.lock with pyproject.toml (v1.83.6 -> v1.83.7) 2026-04-14 11:05:25 -07:00
Ishaan Jaffer
e20c114811
fix(mcp): set instructions=None in SigV4BuildFromTable test mocks
New MCPServer.instructions field requires a str; MagicMock attributes
not explicitly set return a MagicMock object, which fails Pydantic
validation.
2026-04-14 11:05:22 -07:00
Sameer Kankute
b8f7d61400
Merge pull request #25589 from BerriAI/litellm_oss_staging_04_11_2026
Litellm oss staging 04 11 2026
2026-04-14 23:34:25 +05:30
Sameer Kankute
b1c77d22f0
Merge pull request #25192 from BerriAI/litellm_oss_staging_04_04_2026
litellm_staging_04_04_2026
2026-04-14 23:33:16 +05:30
Krrish Dholakia
6d2b94261a fix(mypy): resolve type errors in compression/compress.py and __init__.py
Cast message lists to the expected `List[Union[AllMessageValues, Message]]`
type at `token_counter` call sites, and suppress the `no-redef` warning for
the `compress` import in `__init__.py` caused by the wildcard `main` import.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-14 10:54:31 -07:00
ishaan-berri
4a71583951
Merge pull request #25348 from BerriAI/litellm_gemini-veo-video-resolution-pricing2
feat(gemini): Veo Lite pricing, video resolution usage and tiered cost
2026-04-14 10:23:22 -07:00
ishaan-berri
e2fc7d64e8
Merge pull request #25396 from BerriAI/litellm_bedrock-normalize-custom-tool-schema
feat(bedrock): normalize custom tool JSON schema for Invoke and Converse
2026-04-14 10:21:15 -07:00
Ryan Crabbe
6da4e0b901
fix(ui): pre-select backend default for boolean guardrail provider fields
Boolean fields in the auto-generated guardrail provider form (e.g. Noma
`use_v2`) rendered as empty Selects because the Form.Item only populated
`initialValue` for percentage fields, and the `defaultValue` passed to the
Select child was silently dropped by antd's controlled-component wrapper.
Users could not tell what the backend default was, and the visual ambiguity
made flags like `use_v2` look inoperative even though the save path worked.

Unify `initialValue` to fall back through `fieldValue → field.default_value →
(percentage ? 0.5 : undefined)`, and switch Select.Option values from
"true"/"false" strings to real booleans so the backend default flows through
without stringification.
2026-04-14 10:13:58 -07:00
ishaan-berri
693c846617
Merge pull request #25674 from BerriAI/litellm_anthropic-messages-thinking-signature-retry
feat(anthropic): retry /v1/messages after invalid thinking signature
2026-04-14 10:10:43 -07:00
Lucas Song
9c869732a5 fix(ui): remove unused useMutation import and add React import to test 2026-04-14 10:08:18 -07:00
Lucas Song
977245c30e fix(ui): rename test file to tsx and remove unused useMutation import 2026-04-14 10:08:07 -07:00
ishaan-berri
9810a1b3b7
Merge pull request #25344 from BerriAI/litellm_Sameerlite/healthcheck-max-tokens
feat(health-check): add BACKGROUND_HEALTH_CHECK_MAX_TOKENS env var
2026-04-14 10:04:50 -07:00
Lucas Song
ef774a1991 Merge remote-tracking branch 'origin/main' into fix-ui-policy-attachment-delete 2026-04-14 10:02:23 -07:00
Lucas Song
53828dda76 refactor: migrate policy attachment deletion to useMutation hook with tests 2026-04-14 09:54:41 -07:00
ishaan-berri
f6058bd0ca
Merge pull request #25673 from michelligabriele/fix/responses-api-cache-key
fix(caching): add Responses API params to cache key allow-list
2026-04-14 09:53:05 -07:00
ishaan-berri
d479234f0e
Merge pull request #25694 from milan-berri/feat/mcp-initialize-instructions
feat(mcp): expose per-server InitializeResult.instructions from gateway
2026-04-14 09:51:07 -07:00
ishaan-berri
15ef3fa8ca
Merge pull request #25679 from michelligabriele/fix/azure-passthrough-standard-logging-object
fix(azure/passthrough): populate standard_logging_object via logging hook
2026-04-14 09:38:33 -07:00
Sameer Kankute
69bf2bfb9a
Fix tests 2026-04-14 21:18:23 +05:30
Sameer Kankute
a0e61a9d49
Fix code qa 2026-04-14 21:01:39 +05:30
Sameer Kankute
ee40da58a2
Merge branch 'main' into litellm_oss_staging_04_11_2026 2026-04-14 20:54:12 +05:30
Sameer Kankute
ffb87dcac9
Fix failing test and code qa + lint 2026-04-14 20:53:17 +05:30
Sameer Kankute
ef94f5fc4d
Fix budget reset test 2026-04-14 20:50:42 +05:30
Sameer Kankute
f6e526c5be
Fix bulk update tests 2026-04-14 20:46:21 +05:30
Sameer Kankute
3d567c34dd
Merge pull request #25698 from BerriAI/revert-25395-fix/25388-embedding-encoding-format
Revert "fix(embedding): omit null encoding_format for openai requests"
2026-04-14 20:37:35 +05:30
Sameer Kankute
e6771feace
Revert "fix(embedding): omit null encoding_format for openai requests (#25395)"
This reverts commit e3d160f158.
2026-04-14 20:36:28 +05:30
Sameer Kankute
972e42c7fd
Merge branch 'main' into litellm_oss_staging_04_04_2026 2026-04-14 20:23:06 +05:30
Milan
e7c630ed19
refactor: inline get_upstream_initialize_instructions
Remove the trivial one-line wrapper and access the dict directly.

Made-with: Cursor
2026-04-14 15:59:00 +03:00
Milan
7e656f4329
test: add unit tests for MCP initialize instructions feature
Extend existing test modules with coverage for the instructions merge
logic, upstream cache, ContextVar-based injection, and client-side
capture — following each file's established patterns.

Made-with: Cursor
2026-04-14 15:54:27 +03:00
Milan
8c2ebee4de
refactor(mcp): reuse existing sessions for initialize instructions
Remove the gateway-specific initialize fetch path and reuse instructions captured during existing MCP calls (list_tools/health_check/call_tool), while keeping YAML/DB instructions as immediate overrides.

Made-with: Cursor
2026-04-14 14:46:06 +03:00
Milan
96ed00e184
feat(mcp): gateway InitializeResult.instructions from upstream or YAML
- Add optional instructions on MCPServer (config/DB/types) and Prisma migration.
- MCPClient: fetch_upstream_initialize_instructions() for one-shot initialize.
- Gateway merges per-request instructions: YAML/API overrides; otherwise fetch
  upstream initialize instructions (skip spec_path/OpenAPI-only servers).
- Pass auth headers into instruction merge; ContextVar for gateway Server.
- REST: wire instructions on connection-test MCPServer payloads.

Made-with: Cursor
2026-04-14 14:19:31 +03:00