Commit Graph
5648 Commits
Author SHA1 Message Date
Sameer KankuteandGitHub d879dcdcef Revert "Fix/prisma schema permission (#19391)"
This reverts commit 75ee0d126c.
2026-01-21 17:19:32 +05:30
Sameer KankuteandGitHub a1aba2ed8d Merge pull request #19491 from BerriAI/main
merge main 20 1 25
2026-01-21 16:40:48 +05:30
Sameer Kankute c571a02f3b Filter out unsupported fields from JSON schema for Anthropic's output_format API. 2026-01-21 15:48:22 +05:30
Sameer Kankute 3a0d166eb0 Fix: tool call streaming in chat completino brigde 2026-01-21 12:14:02 +05:30
Yuta Saito caf5f7f8ae test: add test 2026-01-21 14:51:56 +09:00
Sameer Kankute a5ea08a0bf Fix test_default_api_base failing because of chatgpt as provider 2026-01-21 09:32:38 +05:30
Ryne CarboneandGitHub 15013cec4b feat(gemini): add file content support in tool results (#19416)
Add support for 'file' and 'input_file' content types in
convert_to_gemini_tool_call_result(). File content in tool
results was previously silently dropped.

Supports base64 data URIs and HTTP URLs, matching the existing
image handling pattern. Enables PDF, audio, video, and other
file types as inline_data for Gemini.
2026-01-20 19:54:12 -08:00
Cesar GarciaandGitHub b4ed387d24 fix(vertex_ai): handle reasoning_effort as dict from OpenAI Agents SDK (#19419)
The OpenAI Agents SDK (v0.6.9+) now passes reasoning_effort as a dict
when summary is specified: {"effort": "high", "summary": "auto"}

This change extracts the "effort" value from the dict for Vertex AI,
which only supports thinkingLevel (not summary).

Before: reasoning_effort={"effort": "high"} was silently ignored
After: reasoning_effort={"effort": "high"} correctly maps to thinkingLevel

Fixes #19411
2026-01-20 19:31:25 -08:00
Sameer Kankute 0b9f6b543f Fixes test_aaabasic_gcs_logger 2026-01-21 08:58:16 +05:30
SampsonandGitHub 09941dd1d1 add search provider for brave search api (#19433)
* add search provider for brave search api

Introduces a minimal implementation of the Brave Search API as a search provider. Additionally, this PR introduces a test file to ensure the provider works properly, and numerous other smaller changes (e.g., changes to docs to mention the new option).

* Update transformation.py
2026-01-20 19:23:29 -08:00
Kamil JopekandGitHub ce722ab763 Make grpc dependency optional (#19447)
* Make grpc optional and document gRPC OTEL setup

* Add tests for missing OTLP gRPC imports
2026-01-20 19:03:52 -08:00
Harshit JainandGitHub 3c3148789a fix: resolve Read-only file system error in non-root images (#19449) 2026-01-20 19:00:52 -08:00
Harshit JainandGitHub b36e704e06 fix: ensure auto-rotation updates existing AWS secret instead of creating new one (#19455) 2026-01-20 18:30:36 -08:00
Ishaan Jaffer 0d75e506c5 fix mock_handler 2026-01-20 18:01:22 -08:00
Ishaan Jaffer b9de10bd27 test token ctr 2026-01-20 17:53:53 -08:00
yuneng-jiangandGitHub 96b2d134a7 Revert "[Infra] Changing Google Tests to use Gemini 3 Flash Preview" 2026-01-20 17:32:10 -08:00
Ishaan JaffandGitHub ddebdd47bc [Feat] Add Support for Claude Code Max/OAuth 2 on LiteLLM AI Gateway (#19453)
* fix count_tokens_with_anthropic_api

* remove outdated file

* fix ANTHROPIC_TOKEN_COUNTING_BETA_VERSION

* refactor: get_token_counter

* init test suite for token counter

* init token counters

* fix: fix pyrightI

* fix Code QA issues

* feat: add OAUTH handling ant

* feat: Oauth handling Ant

* test anthopic common utils

* fix code QA

* docs
2026-01-20 17:21:17 -08:00
yuneng-jiangandGitHub 351e3a5f3c Merge pull request #19456 from BerriAI/litellm_cicd_fix_yj_05
[Infra] Changing Google Tests to use Gemini 3 Flash Preview
2026-01-20 17:15:03 -08:00
yuneng-jiang 0dc92a6979 changing to gemini 3 flash preview 2026-01-20 17:14:06 -08:00
yuneng-jiang 65829411e0 increasing time for spend tracking 2026-01-20 16:31:25 -08:00
yuneng-jiangandGitHub d5305c6a61 Merge pull request #19450 from BerriAI/litellm_cicd_fix_yj_02
[Infra] Fix test_route_checks
2026-01-20 16:22:20 -08:00
yuneng-jiang 1a9a7df437 use mock db for cluade code marketplace 2026-01-20 16:18:21 -08:00
yuneng-jiang 232ae52b94 attempt test_route_checks fix 2026-01-20 15:55:44 -08:00
Harshit JainandGitHub 20323feecc fix(prompts): fix prompt info lookup and delete using correct IDs (#19358)
* fix(prompts): fix prompt info lookup and delete using correct IDs

* add regression tests cases
2026-01-20 12:28:34 -08:00
Kris XiaandGitHub 56bf6001e9 Supports setting media_resolution and fps parameters on each video file, when using Gemini video understanding. (#19273)
* feat: add gemini video metadata and detail support

Implement support for video_metadata and enhanced detail parameter
for Gemini 3.0+ models:

- Add video_metadata field to ChatCompletionFileObjectFile type
  - Supports fps, start_offset, and end_offset parameters
  - Properly converts snake_case to camelCase for Gemini API
- Extend detail parameter to support medium and ultra_high levels
  - Maps to MEDIA_RESOLUTION_MEDIUM and MEDIA_RESOLUTION_ULTRA_HIGH
- Update _process_gemini_image to handle video metadata transformation
- Add version gating to only apply features for Gemini 3+ models
- Add comprehensive test coverage (6 new test cases)
  - Test detail parameter with file objects
  - Test video_metadata fields (fps, start_offset, end_offset)
  - Test combined detail + video_metadata usage
  - Test new detail levels (medium, ultra_high)
  - Test version gating (Gemini 1.5 vs 3.0)

Note: video_metadata is only supported for video files but error
handling is delegated to Vertex AI for other media types.

* refactor: rename _process_gemini_image to _process_gemini_media

The function handles multiple media types (images, audio, video, PDF),
not just images. Renamed to better reflect its actual purpose.

- Update function name in transformation.py
- Update all function calls and references
- Update test names and imports to match
- Improve docstring to clarify it handles all media types

* docs: add video metadata and media resolution control documentation

Add comprehensive documentation for Gemini 3+ video processing features:
- Document media resolution control (detail parameter) for images and videos
- Add video_metadata field documentation (fps, start_offset, end_offset)
- Include usage examples with tabs for basic, combined, and proxy scenarios
- Update both Gemini and Vertex AI provider documentation
- Clarify snake_case to camelCase field conversion for Gemini API

Signed-off-by: Kris Xia <xiajiayi0506@gmail.com>

* refactor(gemini): extract metadata application into helper function

Extract duplicated Gemini 3+ media_resolution and video_metadata
application logic from _process_gemini_media into a dedicated
_apply_gemini_3_metadata helper function to improve code maintainability.

---------

Signed-off-by: Kris Xia <xiajiayi0506@gmail.com>
2026-01-20 11:36:55 -08:00
Harshit JainandGitHub 75ee0d126c Fix/prisma schema permission (#19391)
* fix: add prisma permission issue

* Add test case for prisma generate
2026-01-20 09:53:16 -08:00
Sameer KankuteandGitHub 11dbae85d1 Merge pull request #19390 from BerriAI/litellm_consistent_id_streaming_responses
Fix: ID mismatch between text-start and text-delta
2026-01-20 20:46:34 +05:30
Sameer KankuteandGitHub 9e1275b76c Merge branch 'main' into litellm_staging_01_19_2026 2026-01-20 19:19:36 +05:30
Sameer KankuteandGitHub a3c1f4758d Merge branch 'main' into litellm_consistent_id_streaming_responses 2026-01-20 19:02:23 +05:30
Sameer KankuteandGitHub e69c12b6db Merge pull request #19396 from BerriAI/litellm_responses_route_fix
Fix for Prometheus Metric Cardinality Issue with /responses Endpoint
2026-01-20 19:01:18 +05:30
Sameer KankuteandGitHub 3cc19c56ba Revert "feat: Add Redis-based migration lock with bug fixes (#19261)"
This reverts commit 98e87c3e67.
2026-01-20 18:46:26 +05:30
Sameer Kankute dc3ee63359 fix: test_env_keys 2026-01-20 18:37:56 +05:30
Sameer Kankute 2153db5e64 fix: test_convert_to_bedrock_format_post_call_streaming_hook 2026-01-20 18:27:36 +05:30
Sameer Kankute 8b24720638 fix: test_standard_logging_payload_includes_guardrail_information 2026-01-20 18:21:32 +05:30
Sameer Kankute cd96c8cbb0 Fix:test_aaaaazure_tenant_id_auth 2026-01-20 17:39:08 +05:30
Sameer Kankute f0785d5a51 Fix:test_supported_params_limited_to_docs 2026-01-20 17:26:40 +05:30
Sameer KankuteandGitHub dd6b35e825 Merge pull request #19401 from BerriAI/main
Merge main 01 20 2026
2026-01-20 16:45:08 +05:30
Sameer KankuteandGitHub deb9142117 Merge pull request #19400 from BerriAI/main
merge main iin 19/1 staging
2026-01-20 16:45:01 +05:30
Sameer Kankute 5f80e8d5e8 Fix for Prometheus Metric Cardinality Issue with /responses Endpoint 2026-01-20 15:28:09 +05:30
Sameer Kankute f945fd9a84 Fix: ID mismatch between text-start and text-delta 2026-01-20 11:15:37 +05:30
Sameer KankuteandGitHub 3eb3594ab7 Merge pull request #19346 from Chesars/fix/drop-params-prompt-cache-key-19225
fix: drop_params not dropping prompt_cache_key for non-OpenAI providers
2026-01-20 10:15:45 +05:30
Sameer KankuteandGitHub 931998f170 Merge pull request #19266 from VedantMadane/fix-prompt-caching-string-content
Fix extract_cacheable_prefix to handle string content with message-level cache_control
2026-01-20 10:11:48 +05:30
victorigualadaandGitHub 7d6d419a67 fix: preserve tool output ordering for gemini in responses bridge (#19360)
* fix: preserve tool output ordering for gemini in responses bridge

- Keep function_call_output adjacent to its function_call when building chat messages
- Normalize function_call_output.output lists (input_* parts) into tool message content

* fix test

* small improvements
2026-01-19 20:37:59 -08:00
victorigualadaandGitHub 581d086c20 fix(responses): stream tool call events in completion bridge (#19368)
Emit Responses API streaming events for tool calls when the underlying chat stream contains tool_call deltas, and recover tool calls into the stream when they only appear in the final response.
2026-01-19 20:29:50 -08:00
Sameer KankuteandGitHub 2ae308028d Merge pull request #18787 from aproorg/fix/bedrock-thinking-tool-call-2
fix(bedrock): handle thinking with tool calls for Claude 4 models
2026-01-20 09:43:07 +05:30
YutaSaitoandGitHub 00814d4d90 Merge pull request #19379 from BerriAI/litellm_feat_mcp_version_up
[feat] mcp version up
2026-01-20 13:09:29 +09:00
Sameer Kankute a4bfdf2427 Fix: total timeout is not respected 2026-01-20 09:37:43 +05:30
Yuta Saito ab11ceff32 tests: patch MCP client mocks via module alias to avoid real network calls 2026-01-20 12:31:27 +09:00
이명현andGitHub 0dfc3fad5a Fix: bedrock invoke claude 4 optional params #19318 (#19381) 2026-01-19 19:14:58 -08:00
Ryan MalloyandGitHub 58c8c2b7b1 fix: HTTP client memory leaks in Presidio, OpenAI, and Gemini (#19190)
* fix: prevent HTTP client memory leaks in Presidio and OpenAI wrappers

Fixes multiple memory leak issues reported in #14540 and related tickets:

**Presidio Guardrail Fix (#14540)**
- Problem: Every guardrail check created a new aiohttp.ClientSession
- Impact: High-traffic proxies accumulated thousands of unclosed sessions
- Solution: Share a single session across all guardrail checks
  - Added `self._http_session` instance variable
  - Lazy session creation via `_get_http_session()`
  - Proper cleanup via `_close_http_session()` and `__del__()`
- Files: litellm/proxy/guardrails/guardrail_hooks/presidio.py

**OpenAI HTTP Client Caching (#14540)**
- Problem: `_get_async_http_client()` created new httpx.AsyncClient on each call
- Impact: OpenAI/Azure completions bypassed client caching system
- Solution: Route through `get_async_httpx_client()` for TTL-based caching
  - Caches clients by provider and SSL config
  - Fallback to direct creation if caching fails
  - Applied to both async and sync client methods
- Files: litellm/llms/openai/common_utils.py

**Test Script**
- Added validation script to demonstrate fixes
- Counts file descriptors and unclosed session objects
- Files: test_oom_fixes.py

Related issues: #14384, #13251, #12443

* fix(oom): prevent memory leaks in Presidio guardrails and OpenAI client creation

Fixes two high-impact memory leaks:

1. Presidio Guardrail Session Leak (issue #14540)
   - Problem: Created new aiohttp.ClientSession on every guardrail check
   - Impact: Runs on EVERY proxy request when PII masking enabled
   - Fix: Shared session pattern with lifecycle management
   - Files: litellm/proxy/guardrails/guardrail_hooks/presidio.py

2. OpenAI HTTP Client Cache Bypass (issue #14540)
   - Problem: _get_async_http_client() created new httpx.AsyncClient, bypassing TTL cache
   - Impact: Every completion created new client with own connection pool
   - Fix: Route through get_async_httpx_client() for proper caching
   - Critical: Include SSL config in cache key for correctness
   - Files: litellm/llms/openai/common_utils.py

Validation:
- Presidio: 100 requests → 0 new sessions (was 100)
- OpenAI: 100 calls → 1 unique client (was 100)
- test_oom_fixes.py: Automated validation script

* fix(oom): resolve Gemini aiohttp session leak (issue #12443)

Fixes persistent "Unclosed client session" warnings when using Gemini models.

Root Causes:
1. Broken atexit cleanup - get_event_loop() fails at exit time
2. On-demand session creation without reliable cleanup

Changes:

1. Fixed atexit Cleanup (async_client_cleanup.py)
   - OLD: Used get_event_loop() which fails when loop is closed
   - NEW: Always create fresh event loop at exit time
   - Ensures cleanup runs successfully even when main loop is closed

2. Added __del__ Cleanup (aiohttp_handler.py)
   - Defense-in-depth: cleanup on garbage collection
   - Handles abnormal termination cases
   - Similar pattern to Presidio guardrail fix

3. Enhanced Cleanup Scope (async_client_cleanup.py)
   - Now closes global base_llm_aiohttp_handler instance
   - Previously only checked cache, missed module-level handler

Validation:
- Test 1: __del__ cleanup → 0 sessions leaked ✓
- Test 2: atexit cleanup → 0 sessions leaked ✓
- test_gemini_session_leak.py: Automated validation

Related: #14540 (broader OOM issue tracking)

* fix(types): use LlmProviders enum for get_async_httpx_client

MyPy was failing because llm_provider parameter expects Union[LlmProviders, httpxSpecialProvider], not a string.

Changed from string "openai" to LlmProviders.OPENAI enum value.

* test: move validation tests to proper CI directories

- Move test_oom_fixes.py to tests/test_litellm/llms/
- Move test_gemini_session_leak.py to tests/test_litellm/llms/custom_httpx/
- Fix pytest warning: use pytest.skip() instead of return True

This ensures CI actually runs our OOM fix validation tests.

* fix(oom): add asyncio.Lock to prevent race conditions in Presidio session creation

- Make _get_http_session() async with asyncio.Lock protection
- Prevents multiple concurrent requests from creating orphaned sessions
- Add concurrent load test (50 parallel requests) to validate fix
- Test confirms only 1 session created under concurrent load

Critical fix: Previous implementation had race condition where
concurrent guardrail checks could create multiple sessions,
defeating the shared session pattern and causing memory leaks.

* fix(presidio): eliminate race condition in session lock initialization

Move asyncio.Lock creation from lazy initialization in _get_http_session()
to __init__. The previous lazy init had a race condition where concurrent
coroutines could both see _session_lock as None, both create locks, and
end up with different lock instances - defeating the synchronization.

asyncio.Lock() can be safely created without an event loop; it only
requires one when awaited.
2026-01-19 19:02:55 -08:00