Commit graph

35025 commits

Author SHA1 Message Date
Yuneng Jiang
5fd129367e
chore: fixes
Some checks failed
Unit Tests: Caching (Redis) / caching-redis (push) Has been cancelled
Unit Tests: Proxy DB Operations / proxy-db (auth-checks, tests/proxy_unit_tests/test_auth_checks.py tests/proxy_unit_tests/test_user_api_key_auth.py, 20, 8) (push) Has been cancelled
Unit Tests: Proxy DB Operations / proxy-db (key-generation, tests/proxy_unit_tests/test_key_generate_prisma.py, 30, 0) (push) Has been cancelled
Unit Tests: Proxy DB Operations / proxy-db (remaining, tests/proxy_unit_tests --ignore=tests/proxy_unit_tests/test_key_generate_prisma.py --ignore=tests/proxy_unit_tests/test_auth_checks.py --ignore=tests/proxy_unit_tests/test_user_api_key_auth.py, 20, 8) (push) Has been cancelled
Unit Tests: Security / security (push) Has been cancelled
2026-04-05 00:43:57 -07:00
Ryan Crabbe
4afcbc9d66 Guard against stdio transport with session caching and fix review issues
- Raise ValueError when use_session_cache=True with stdio transport
  (stdio spawns child processes that can become orphans if cached)
- Fix duplicate _create_transport_context method (second shadowed first)
- Fix concurrent retry stampede (identity check before replacing session)
- Add _closed guard to prevent operations after close()
- Improve _is_connection_error to use type-name matching (no false positives)
- Remove unused orig variable in tests
- Add tests for stdio caching guard
2026-03-11 11:29:38 -07:00
Ryan Crabbe
62121806d9 Add tests for MCP session caching behavior
Add retry and concurrency coverage for MCPClient session cache to ensure robust connection pooling under failures and parallel calls.

Made-with: Cursor
2026-03-11 09:46:31 -07:00
Ryan Crabbe
6534a0c8ef Add MCP client session caching for improved performance
Implement optional session caching in MCPClient to reuse connections
instead of creating new ones for every tool call.

Changes:
- Add use_session_cache and session_cache_ttl parameters to MCPClient
- Implement run_with_cached_session() for connection reuse
- Use idle timeout (resets on each use) so active connections stay alive
- Add close() method for explicit resource cleanup
- Extract shared transport creation into _create_transport_context()

Defaults to disabled (use_session_cache=False) for backwards compatibility.
2026-03-11 08:51:49 -07:00
Joe Reyna
cbbd51a5ce
fix(codeql): switch to security-extended to fix OOM failures (#23226)
* fix(codeql): switch to security-extended query suite

The security-and-quality suite produces result sets > 2 GiB on this
codebase, causing fatal OOM failures and blocking CI. Switching to
security-extended reduces query scope to security-only checks, which
still complete successfully. Quality/maintainability checks are
already covered by the existing lint pipeline.

* fix(codeql): exclude OOM queries from security-extended
2026-03-11 07:38:01 -07:00
Joe Reyna
7d2cc4a3bf
fix(ui): import MCPEvent type into local scope in chat/types.ts (#23330) 2026-03-11 07:37:24 -07:00
Harshit Jain
7db34e3179
Merge pull request #23257 from Harshit28j/litellm_fix-client-close-evict
fix: fail proxy startup if prisma migrate fails
2026-03-11 19:45:13 +05:30
Sameer Kankute
d99ddc67d4
Merge pull request #23338 from BerriAI/litellm_fix_multipart_passthrough
fix(proxy): preserve multipart/form-data boundary in passthrough endpoints
2026-03-11 19:30:54 +05:30
Sameer Kankute
8e32919074
Merge branch 'main' into litellm_fix_multipart_passthrough 2026-03-11 19:30:45 +05:30
Sameer Kankute
20980f6c26
Merge pull request #23322 from BerriAI/litellm_gemini_embedding_2_support
[Feat]: Add support for gemini embedding 2 preview
2026-03-11 19:30:09 +05:30
michelligabriele
db4cd87979
docs(web_fetch): add newer Claude models to supported models list (#23251)
Add Claude Opus 4.6, Sonnet 4.6, Opus 4.5, Sonnet 4.5, and Haiku 4.5
to the web fetch supported models documentation. These models were
missing from the list despite supporting the web_fetch tool.
2026-03-11 19:09:28 +05:30
Sameer Kankute
ff2fe96717
Merge pull request #23276 from BerriAI/litellm_oss_staging_03_10_2026
Litellm oss staging 03 10 2026
2026-03-11 18:54:38 +05:30
Sameer Kankute
f243e5615f
Merge branch 'main' into litellm_oss_staging_03_10_2026 2026-03-11 18:50:03 +05:30
Sameer Kankute
2343149f2d
Merge pull request #23163 from BerriAI/litellm_oss_staging_03_04_2026
Litellm oss staging 03 04 2026
2026-03-11 18:46:51 +05:30
Sameer Kankute
43217c8a4b
Merge branch 'main' into litellm_oss_staging_03_10_2026 2026-03-11 18:32:17 +05:30
Sameer Kankute
3dab62023c Merge branch 'main' into litellm_oss_staging_03_04_2026 2026-03-11 18:31:20 +05:30
Sameer Kankute
c2fca1124b fix(proxy): preserve multipart/form-data boundary in passthrough endpoints
Fixes issue where multipart file uploads through passthrough endpoints failed with RequestValidationError. The proxy was consuming the request body stream and FastAPI was trying to parse multipart bodies as JSON dicts.

Changes:
- Try JSON parsing first for multipart content-type (handles misconfigured clients)
- Skip multipart parsing if JSON succeeds to avoid stream consumption
- Remove custom_body parameter from endpoint_func to prevent FastAPI auto-parsing
- Check for parsed body before using multipart handler
- Add regression test for multipart boundary preservation

Handles both actual multipart uploads and JSON bodies with incorrect multipart content-type headers.

Made-with: Cursor
2026-03-11 16:52:02 +05:30
yuneng-jiang
628510d1b5
Merge pull request #23298 from BerriAI/litellm_/silly-pasteur
[Test] UI - Logs: Add unit tests for view_logs components
2026-03-11 00:57:26 -07:00
yuneng-jiang
09e2676e85
Merge pull request #23328 from BerriAI/litellm_mcp_recheck_health
[Feature] UI - MCP Servers: Per-server health recheck
2026-03-11 00:56:44 -07:00
yuneng-jiang
fdf925a3a3 [Feature] UI - MCP Servers: Add per-server health recheck
Allow users to recheck health for individual MCP servers by clicking
the health status badge. On hover the badge text changes to "Recheck"
with a refresh icon, and the check runs only for that server.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 00:54:25 -07:00
Sameer Kankute
a6fb16aea0
Merge pull request #23103 from netbrah/fix/anthropic-tool-schema-type-enforcement
fix(anthropic): enforce type:"object" on tool input schemas in _map_tool_helper
2026-03-11 13:06:59 +05:30
Sameer Kankute
b9a311743f
Merge pull request #23104 from netbrah/fix/anthropic-deduplicate-tool-results
fix(anthropic): deduplicate tool_result messages by tool_call_id
2026-03-11 13:04:59 +05:30
yuneng-jiang
4f36d29d0c
Merge pull request #23326 from BerriAI/litellm_mcp_permissions_yj
[Fix] MCP Key Scope Type Fix
2026-03-11 00:27:18 -07:00
yuneng-jiang
ff2f96d09e Fix mcp_tool_permissions JSON string deserialization in _resolve_team_allowed_mcp_servers
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 00:23:40 -07:00
yuneng-jiang
b48682f61a
Merge pull request #23323 from BerriAI/litellm_mcp_permissions_yj
[Feature] MCP Server Team-Scoped Filtering for Key Creation
2026-03-11 00:20:19 -07:00
yuneng-jiang
860cb17571 Fix cross-team MCP server info disclosure and restricted key bypass
The GET /v1/mcp/server endpoint allowed any authenticated user to pass
an arbitrary team_id and enumerate another team's MCP server config.
Restricted virtual keys could also use the team_id param to bypass
their access limitations. Add team membership check for non-admins
and block restricted keys from using the team_id filter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 23:48:30 -07:00
Sameer Kankute
e394914d34 Fix code qa 2026-03-11 11:49:02 +05:30
yuneng-jiang
c362ae5095 Add team-scoped MCP server filtering for key creation and fix UnboundLocalError
When creating a key, the MCP server list now filters by the selected team's
allowed servers. Also fixes UnboundLocalError on `is_restricted_virtual_key`
when `team_id` query param was provided to GET /v1/mcp/server.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 23:15:14 -07:00
Sameer Kankute
2a9bcf2530 Fix greptile reviews 2026-03-11 11:41:29 +05:30
Sameer Kankute
1c144fc896 Add embedding model documentation 2026-03-11 11:02:49 +05:30
Sameer Kankute
8c5478df70 Add embedding model in model map 2026-03-11 10:58:50 +05:30
Sameer Kankute
d25b8e6d00 Add support for gcs url for vertex ai embeddings 2026-03-11 10:58:04 +05:30
Sameer Kankute
2c4a495619 Add support for vertex ai gemini multimodal embedings 2026-03-11 10:39:34 +05:30
Sameer Kankute
b108c02fd7 Add support for gemini multimodal embedings 2026-03-11 10:08:17 +05:30
Joe Reyna
40210ce750
fix(codeql): remove ruby from language matrix (#23227) 2026-03-10 20:45:23 -07:00
Ishaan Jaff
65842eb7b5
[Feat] UI - Show logos on MCP Apps page (#23320)
* feat(ui): add MCP server logo support across admin and chat UIs

- New MCPLogoSelector component with grid of well-known logos (GitHub,
  Slack, Notion, Linear, Jira, etc.) and custom URL input
- Create MCP Server form: logo picker with preview, OpenAPI presets
  auto-fill logo from registry icon_url
- Edit MCP Server form: logo picker pre-populated from mcp_info.logo_url
- Admin table: logos rendered next to server name in Name column
- Chat MCPAppsPanel: logos on server cards (list + detail view) with
  graceful fallback to letter avatars
- Chat MCPConnectPicker: logos next to server names in toggle list
- Fix pre-existing bug: setTools -> clearTools in create form cancel
- All 321 vitest files / 3211 tests pass

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

* feat(ui): use local SVG logos for MCP services, fix Chat UI rendering

- Add 15 new MCP service logo SVGs (Slack, Notion, Linear, Jira, Figma,
  Gmail, Stripe, Salesforce, Shopify, HubSpot, Twilio, Sentry, Zapier,
  GitLab, Google Drive) to both source and pre-built directories
- Switch MCPLogoSelector from CDN URLs (cdn.simpleicons.org) to local
  asset paths (/ui/assets/logos/) for reliable rendering
- Logos now served by the proxy itself, working from any page path
  including /ui/chat/ (absolute paths resolve correctly everywhere)

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-10 20:27:13 -07:00
Cesar Garcia
260c37d670
Merge pull request #21398 from Chesars/feat/openai-like-responses-api
feat(openai_like): add Responses API support to JSON providers
2026-03-11 00:15:06 -03:00
Chesars
da76e1738a fix(perplexity): restore type='message' safety net for list inputs
Perplexity requires type='message' on input items. Add _ensure_message_type
to automatically set it when missing, matching the old _format_input behavior.
2026-03-11 00:14:13 -03:00
Cesar Garcia
5e32ace260
Update litellm/types/llms/openai.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-11 00:11:01 -03:00
Sameer Kankute
3ed9b3595d
Merge pull request #23135 from FacerAin/main
feat(model): add qwen3.5 series for openrouter
2026-03-11 08:34:02 +05:30
Chesars
ff97b0584a revert: remove unrelated supports_web_search addition from o4-mini models 2026-03-11 00:00:55 -03:00
Chesars
6bb29051dc refactor: remove perplexity from providers.json
Perplexity has a dedicated Python class (PerplexityResponsesConfig) that
always takes priority over JSON config. The JSON entry was dead code.
2026-03-10 23:58:04 -03:00
Chesars
636b474a8a fix(perplexity): remove redundant dict-cost check in Usage and add streaming cost test
Remove the isinstance(cost, dict) guard from Usage.__init__ — ResponseAPIUsage.parse_cost
validator already converts Perplexity's cost dict to float before it reaches Usage.

Add test_streaming_cost_dict_to_float_via_validator to verify the dict→float conversion
works end-to-end through transform_streaming_response (pydantic recursive construction).
2026-03-10 23:52:17 -03:00
Cesar Garcia
0d9afb2200
Merge pull request #23314 from Chesars/feat/model-cost-aliases-clean
feat: add model_cost aliases expansion support
2026-03-10 23:19:29 -03:00
Chesars
4eead432a6 fix: close docstring in _expand_model_aliases 2026-03-10 23:08:06 -03:00
Chesars
8b385120b9 fix: add isinstance guard for aliases field and remove unused helper 2026-03-10 22:58:31 -03:00
Cesar Garcia
7b3621518b
Update litellm/litellm_core_utils/get_model_cost_map.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-10 22:56:27 -03:00
Cesar Garcia
2ed4119542
Update tests/test_litellm/test_model_cost_aliases.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-10 22:56:08 -03:00
Ishaan Jaff
82a9b0ea03
feat(chat-ui): responses API + MCP tool execution in /chat (#23297)
* feat(ui): add Chat UI v0 — standalone LiteLLM-branded chat window

Adds a full chat UI accessible from the sidebar Chat link (opens in new tab).
- Standalone route at /chat (outside dashboard layout — no Navbar/Sidebar chrome)
- Claude.ai-style layout: model selector top-left, LiteLLM logo center, settings top-right
- Greeting with time-of-day, centered input card, suggestion chips (Write/Learn/Code/Brainstorm)
- Sliding conversation history sidebar with Cmd+K search, rename, delete, date grouping
- localStorage-backed conversation persistence (litellm_chat_history_v1)
- Streaming completions via makeOpenAIChatCompletionRequest with AbortController stop support
- MCP server picker (toggle servers on/off per conversation)
- LiteLLM aesthetic: white/light-gray background, Ant Design blue (#1677ff) primary, system font
- Sidebar2: Chat menu item opens in new tab via window.open

* feat(chat-ui): responses API + MCP tool execution display

- Switch /chat from chat completions to responses API (previous_response_id session chaining)
- Add MCP server picker with search filter in chat input bar
- Show MCP tool call events (list_tools + call_tool) inline in chat via MCPEventsDisplay
- Add tool chip strip showing available tools when MCP servers are selected
- Non-blocking MCP toggle: server added immediately, verification in background (works for no-auth MCPs like deepwiki)
- Add truncateAfterMessage to useChatHistory for edit/retry
- Sync activeConversationId on URL change (fixes stale conversation on new chat)
- Add "Open Chat" shortcut button to sidebar

* fix(chat-ui): switch to responses API, remove dead code, add tests

- Switch handleSend from makeOpenAIChatCompletionRequest to makeOpenAIResponsesRequest with previous_response_id session chaining
- Add responsesSessionId state; reset to null when starting a new conversation
- Remove unused ChatInputBar.tsx and ModelSelector.tsx (dead code)
- Add tests/test_litellm/test_chat_ui_responses_session.py covering previous_response_id forwarding and signature validation

* fix(chat-ui): address greptile review issues

- Reset responsesSessionId when activeConversationId changes (not just on new conversation)
- Wire onMCPEvent callback into makeOpenAIResponsesRequest; render MCPEventsDisplay below messages
- Clear mcpEvents on each new send
- Explicitly filter history to user/assistant roles only (no tool-role casting)
- Remove duplicate "Chat" menu item from sidebar (pinned button serves same purpose)
- Make Sider a flex column so "Open Chat" button actually pins to bottom
- Fix tests to intercept real HTTP requests and assert previous_response_id in body

* fix(chat-ui): address greptile review feedback (greploop iteration 1)

- Fix duplicate context: when responsesSessionId is set, only send the
  new user message as input (prior context is already server-side via
  session chaining). Full history is still sent on the first turn.
- Fix ephemeral MCP events: store events per-message in ChatMessage.mcpEvents
  instead of ephemeral component state. Events now survive across turns
  and render inline below each assistant response via MCPEventsDisplay.
- Remove stale mcpEvents useState and ephemeral panel at bottom of chat.

* fix(chat-ui): address greptile review feedback (greploop iteration 2)

- Fix stale session on edit/retry: derive previousResponseId as null when
  historyOverride is set so edit/retry always starts a fresh Responses API
  session rather than chaining off a now-invalid prior session
- Fix unsafe MCPEvent cast: import MCPEvent directly from MCPEventsDisplay
  into types.ts and type ChatMessage.mcpEvents as MCPEvent[], eliminating
  the bare 'as MCPEvent[]' cast in ChatMessages.tsx

* fix(chat-ui): fix MCPEvent layering, batch localStorage writes, module-level test imports

- Move MCPEvent interface definition into chat/types.ts (single source of truth)
- MCPEventsDisplay.tsx now imports MCPEvent from types.ts instead of defining it locally
- Batch MCP event localStorage writes: accumulate during stream, persist once in finally
- Move test imports to module level per PEP 8 convention

* fix(chat-ui): fix MCPEvent import path and rename truncateFromMessage

- responses_api.tsx now imports MCPEvent directly from chat/types (not via MCPEventsDisplay re-export)
- Remove the now-unnecessary MCPEvent re-export from MCPEventsDisplay.tsx
- Rename truncateAfterMessage → truncateFromMessage: the function removes the target message and all subsequent ones (not just what comes after), so the new name accurately describes the behavior

* fix(responses-api): fix whitespace token filter and MCP server URL construction

- Drop the delta.trim() whitespace filter that was silently swallowing spaces
  and newlines during streaming, causing words to concatenate and paragraphs
  to collapse. Only skip truly empty strings (delta.length > 0).
- Use proxyBaseUrl for MCP server_url construction instead of the hardcoded
  relative path "litellm_proxy/mcp", so non-root deployments route correctly.

* fix(responses-api): use unique server_label per MCP server to prevent tool routing collisions

* fix(chat-ui): move MCPEvent to shared mcp_tools/types, skip partial events on abort

- Move MCPEvent interface to mcp_tools/types.tsx (shared with MCPServer/MCPTool),
  eliminating the playground→chat cross-module dependency. chat/types.ts and
  both playground components now import from mcp_tools/types.
- Only persist accumulated MCP events when the stream completes cleanly; aborted
  or errored turns drop partial events to avoid showing incomplete tool calls.

* fix(responses-api): use server_name for MCP URL routing, fix test path

- Use server_name (not alias) as the URL path segment for MCP server_url;
  alias is a display name that may differ from the registered proxy route.
  URL-encode the path to handle names with spaces/special characters.
- Fix sys.path.insert in tests to use __file__-relative path so tests pass
  regardless of which directory pytest is invoked from.

* fix(chat-ui): fix stale session after failed edit, clean MCP event persistence, unique server_label

- Eagerly call setResponsesSessionId(null) when historyOverride is set so a
  failed/aborted edit does not leave a stale session contaminating the next turn
- Replace abort-signal check with streamCompletedCleanly flag to correctly skip
  MCP event persistence on both abort and non-abort errors (network/API failures)
- Use server_name (unique) as server_label instead of alias to prevent silent
  tool-routing failures when two MCP servers share the same display name
2026-03-10 18:53:54 -07:00
Cesar Garcia
f51a5b9c3e
Update tests/test_litellm/test_model_cost_aliases.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-10 22:53:02 -03:00