Commit graph

10183 commits

Author SHA1 Message Date
Sameer Kankute
76176f2a64 fix(file_search): restore should_use_emulated helper, fix dedup, extract DB helper, clean docstring
- Re-add should_use_emulated_file_search() to emulated_handler.py so H5/H6/H7/H13 tests don't fail with ImportError
- Remove per-file-id deduplication from _build_search_results_for_include so all chunks are returned (matching OpenAI native file_search behaviour); update test_H14 to assert 2 results
- Extract raw prisma DB query in check_vector_store_ids_access into a static _fetch_managed_vector_stores_by_uuids helper so the hot request path uses a named, testable function instead of an inline prisma_client.db.* call
- Remove developer-local path from test module docstring

Made-with: Cursor
2026-03-18 11:26:27 +05:30
Sameer Kankute
694cf22c9e
Update tests/test_litellm/llms/vertex_ai/test_vertex_ai_batch_transformation.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-18 11:09:20 +05:30
Krish Dholakia
cec3e9e7d4
Merge pull request #23808 from voidborne-d/fix/shared-aiohttp-session-auto-recovery
fix: auto-recover shared aiohttp session when closed
2026-03-17 22:23:01 -07:00
Sameer Kankute
c4d27cb239 fix(vertex-ai): address greptile review – proxy retrieve URL, timeout forwarding, sync logging
- Fix retrieve_api_base derivation to handle custom proxies with
  path-based routing (not just :cancel suffix)
- Forward timeout to POST calls in cancel_batch (sync + async)
- Add try/except error logging to sync cancel path (parity with async)
- Add tests for timeout forwarding and custom proxy retrieve URL

Made-with: Cursor
2026-03-18 10:30:05 +05:30
yuneng-jiang
41a7747e8c fix: document org scope behavior, fix test mocks, add org admin tests
- Document intentional legacy-matching behavior: when user_id is
  provided to an org admin, no org filter is applied (returns all of
  that user's teams across all orgs, same as legacy endpoint)
- Fix two existing security tests to properly patch user_api_key_cache,
  proxy_logging_obj, and get_user_object instead of relying on
  incidental error handling
- Add three new org admin test cases:
  - Org admin sees org-scoped teams (200 with correct where clause)
  - Org admin rejected when filtering by other org (403)
  - Org admin with user_id filter returns target user's teams

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 21:56:57 -07:00
Sameer Kankute
ecb8c05d37 Add test for reasoning effort none 2026-03-18 10:24:21 +05:30
Sameer Kankute
e46dd949f2 Add test for reasoning effort none 2026-03-18 09:58:20 +05:30
yuneng-jiang
0485a1859a fix: use get_user_object helper, preserve caller org_id filter
- Replace raw find_unique with get_user_object in
  _build_team_list_where_conditions for cache/metrics consistency
- Remove over-complex OR clause for org admin + user_id: when user_id
  is provided, filter by that user's direct team memberships (same as
  regular users) since the access control gate already verified the
  org admin's authority
- Preserve caller-supplied organization_id instead of overwriting with
  org_admin_org_ids
- Update test mock to match get_user_object call path

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 21:19:42 -07:00
Sameer Kankute
d0d593beb8
Update tests/test_litellm/llms/vertex_ai/test_vertex_ai_batch_transformation.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-18 09:48:24 +05:30
Cesar Garcia
6a5b0058e3
Merge pull request #23926 from Chesars/fix/azure-gpt5-4-responses-api-routing
fix(azure): auto-route gpt-5.4+ tools+reasoning to Responses API
2026-03-18 01:14:50 -03:00
Sameer Kankute
74ae17d153 greptile comments 2026-03-18 09:41:46 +05:30
Sameer Kankute
5dd89f16f5 address greptile review: remove unused import, normalize model lookup, add xhigh tests
- Remove unused _get_model_info_helper import
- Normalize model via get_llm_provider in _is_reasoning_effort_level_explicitly_disabled
  so provider-prefixed names (openai/gpt-5.4-mini) resolve correctly
- Add test_gpt5_4_mini_allows_reasoning_effort_xhigh
- Add test_gpt5_4_nano_allows_reasoning_effort_xhigh
- Add test_gpt5_4_mini_provider_prefixed_rejects_minimal
- Extend test_gpt5_minimal_explicitly_disabled_check for openai/gpt-5.4-mini
2026-03-18 09:37:19 +05:30
Sameer Kankute
52bf372319 fix(gpt5): treat missing supports_minimal_reasoning_effort as supported
Add _is_reasoning_effort_level_explicitly_disabled to use opt-out semantics
for minimal effort: unknown/unlisted models pass through, only blocked when
the model map explicitly sets supports_minimal_reasoning_effort=false.

xhigh keeps opt-in semantics (must be explicitly supported).

Adds test for unknown-model passthrough and explicit-disabled detection.

Made-with: Cursor
2026-03-18 09:17:57 +05:30
Cesar Garcia
3c7e37799a
Merge pull request #23928 from Chesars/fix/gemini-context-caching-custom-api-base
fix(gemini): pass model to context caching URL builder for custom api_base
2026-03-18 00:43:16 -03:00
Sameer Kankute
018ccff23f fix(vertex-ai): address greptile review feedback on batch cancel
- Add try/except httpx.HTTPStatusError blocks in _async_cancel_batch for
  both POST cancel and GET retrieve calls, with verbose_logger error logging
- Fix endpoint extraction inconsistency: compute endpoint from URL without
  :cancel suffix so it matches behaviour of create_batch/retrieve_batch
- Add explicit validation that api_base ends with ':cancel' before
  stripping it, raising a descriptive error for unsupported custom proxy
  URL rewriting scenarios
- Use string-based patch() in test instead of patch.object() for robustness
  against import order changes

Made-with: Cursor
2026-03-18 09:11:20 +05:30
Sameer Kankute
6fe3188af0 fix(azure-ai-agents): accumulate annotations from multiple text items in streaming
- Fix bug where only last text item's annotations were preserved when
  thread.message.completed contained multiple text content items
- Accumulate annotations via extend() instead of overwriting
- Add test_azure_ai_agents_streaming_annotations_from_completed_message
- Add test_azure_ai_agents_streaming_accumulates_annotations_from_multiple_text_items

Addresses Greptile review on PR #23849

Made-with: Cursor
2026-03-18 09:04:00 +05:30
Cesar Garcia
f059ba55a9
Merge pull request #23925 from Chesars/fix/mistral-diarize-segments-response
fix(mistral): preserve diarization segments in transcription response
2026-03-18 00:32:53 -03:00
Cesar Garcia
a46b88c237
Merge pull request #23906 from Chesars/fix/anthropic-file-block-cache-control
fix(anthropic): preserve cache directive on file-type content blocks
2026-03-18 00:32:35 -03:00
Cesar Garcia
4947074aac
Merge pull request #23907 from Chesars/fix/vertex-count-tokens-location-override
fix(vertex): respect vertex_count_tokens_location for Claude count_tokens
2026-03-18 00:30:55 -03:00
Cesar Garcia
501ddb428c
Merge pull request #23618 from gambletan/fix/file-to-input-file-mapping
fix: map Chat Completion file type to Responses API input_file
2026-03-18 00:29:06 -03:00
Chesars
8828f002be fix(gemini): pass model to context caching URL builder for custom api_base
_get_token_and_url_context_caching() was hardcoding model=None when
calling _check_custom_proxy(), which raises ValueError when api_base
is set because Gemini proxy URLs need the model name:
{api_base}/models/{model}:cachedContents

Fixes #23846
2026-03-17 23:21:24 -03:00
Chesars
cb15296693 fix(azure): auto-route gpt-5.4+ tools+reasoning to Responses API
Azure GPT-5.4+ models now get the same auto-routing treatment as OpenAI
when both `reasoning_effort` and `tools` are used in `litellm.completion()`.
Previously, `reasoning_effort` was silently dropped for Azure; now the
request is bridged to the Responses API which supports both parameters.

Fixes #23914
2026-03-17 23:06:39 -03:00
Chesars
9afc469725 fix(mistral): preserve diarization segments in transcription response
Fixes #23890 — Mistral's Voxtral transcription with `diarize=true` returns
`segments` (with speaker_id, timestamps) and `language`, but these fields
were dropped when mapping the response to TranscriptionResponse.
2026-03-17 23:04:51 -03:00
Krish Dholakia
5e570b3a66
Merge pull request #23911 from kelvin-tran/fix/cache-control-params-anthropic-document-file-message-blocks 2026-03-17 18:00:05 -07:00
d 🔹
88f59e1465 fix: use AsyncMock for concurrent test consistency
Address review feedback from greptile — use new_callable=AsyncMock
on the concurrent test's patch.object to ensure the mock is properly
typed as async, even though side_effect already handles the coroutine.
2026-03-18 00:54:23 +00:00
Kelvin Tran
c6e9a2a40f
Merge branch 'main' into fix/cache-control-params-anthropic-document-file-message-blocks 2026-03-17 15:34:00 -07:00
Chesars
8f015e2db2 fix(vertex): respect vertex_count_tokens_location for Claude count_tokens
The count_tokens handler unconditionally overrode vertex_location to
us-central1 for Claude models, ignoring the user-configured
vertex_count_tokens_location parameter. Also, us-central1 is no longer
a supported region — Google now supports us-east5, europe-west1, and
asia-southeast1.

Now vertex_count_tokens_location takes precedence, vertex_location is
used as fallback, and us-east5 is the default only when neither is set.

Fixes #23872
2026-03-17 19:14:08 -03:00
Chesars
20f8d413e5 fix(anthropic): preserve cache_control on file-type content blocks
Fixes #23873
2026-03-17 19:10:19 -03:00
Cesar Garcia
1f5a67ab45
Merge pull request #23895 from Chesars/fix/streaming-tool-call-finish-reason-empty-content
fix(vertex): streaming finish_reason='stop' instead of 'tool_calls' for gemini-3.1-flash-lite-preview
2026-03-17 18:49:27 -03:00
Cesar Garcia
c1db67ab67
Merge pull request #23899 from Chesars/fix/map-anthropic-refusal-finish-reason
fix(core): map Anthropic 'refusal' finish reason to 'content_filter'
2026-03-17 18:49:03 -03:00
Rohan
bed44f5fe5
Add Akto Guardrails to LiteLLM (#23250)
* akto guardrails support in litellm

* docs(guardrails): add akto to supported values in types/guardrails.py

* frontend changes + fixes

* feat(akto): update Akto guardrail integration with new configuration options and modes

* docs(akto): enhance Akto documentation and configuration descriptions for clarity

* feat(tests): add proxy server request headers to sample request data

* refactor(akto): remove optional account and VXLAN IDs; update documentation and tests

* feat(akto): add event_type parameter for enhanced observability in guardrail logging

* refactor(akto): update environment variable references

* refactor the python codes

* refactor and fix linting

* refactor(akto): remove unused event hook and clean up imports

* refactor(akto): enhance AktoGuardrail with async support and improved logging

* fix: Register DynamoAI guardrail initializer and enum entry (#23752)

* fix: Register DynamoAI guardrail initializer and enum entry

Fix the "Unsupported guardrail: dynamoai" error by:
1. Adding DYNAMOAI to SupportedGuardrailIntegrations enum
2. Implementing initialize_guardrail() and registries in dynamoai/__init__.py

The DynamoAI guardrail was added in PR #15920 but never properly registered
in the initialization system. The __init__.py was missing the
guardrail_initializer_registry and guardrail_class_registry dictionaries
that the dynamic discovery mechanism looks for at module load time.

Fixes #22773

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

* Update litellm/proxy/guardrails/guardrail_hooks/dynamoai/__init__.py

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

* Update litellm/proxy/guardrails/guardrail_hooks/dynamoai/__init__.py

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

* test: Add tests for DynamoAI guardrail registration

Verifies enum entry, initializer registry, class registry,
instance creation, and global registry discovery.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

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

* docs: add v1.82.3 release notes and update provider_endpoints_support.json (#23816)

* Revert "docs: add v1.82.3 release notes and update provider_endpoints_support…" (#23817)

This reverts commit 966124966f.

* Refactor Akto guardrail configuration and tests; update UI description and tags

* add account and vxlan ID parameters to Akto guardrail initialization; update Akto logo format

* enhance Akto guardrail documentation and improve error handling for non-JSON responses

* address greptile issues

* fix: update payload handling to use 'data' instead of 'json' in AktoGuardrail and adjust tests accordingly

---------

Co-authored-by: Harshit Jain <48647625+Harshit28j@users.noreply.github.com>
Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: Joe Reyna <joseph.reyna@gmail.com>
Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
2026-03-17 14:38:04 -07:00
Kelvin Tran
d0c5f494a8 fix: cache_control directive dropped anthropic document/file blocks 2026-03-17 14:30:12 -07:00
Chesars
8b4a74a69c fix(core): map Anthropic 'refusal' finish reason to 'content_filter'
Anthropic's 'refusal' stop_reason was missing from _FINISH_REASON_MAP,
causing it to fall through to the default 'stop' — hiding the fact that
the model refused to respond due to safety policies.

Fixes #23793
2026-03-17 18:06:42 -03:00
Chesars
0c28b47057 fix(vertex): streaming finish_reason="stop" instead of "tool_calls" for gemini-3.1-flash-lite-preview
Models like gemini-3.1-flash-lite-preview send the final streaming chunk
with empty content (text:"") alongside finishReason:"STOP", instead of
omitting content entirely. The existing fix (PR #21577) only handled
chunks without content, so this case was missed.

Now, after processing candidates, if tool_calls were seen in earlier
chunks and a choice has finish_reason="stop", it is overridden to
"tool_calls" to match the OpenAI spec.

Fixes #22900
2026-03-17 17:47:01 -03:00
voidborne-d
ca8f5cffa0 style: apply black formatting to fix CI lint check 2026-03-17 18:52:57 +00:00
Xianzong Xie
cb88836486 Add incomplete response error propagation test
Committed-By-Agent: codex
Co-authored-by: codex <noreply@openai.com>
2026-03-17 11:39:12 -07:00
d 🔹
ef22144854 address P2 feedback: add lock docstring warning, remove redundant mock write
- Add WARNING docstring to _get_shared_session_lock() about not resetting
  the lock to None while coroutines may be in the recovery path
- Remove redundant proxy_server_module.shared_aiohttp_session assignment
  in mock_init (add_shared_session_to_data overwrites it synchronously)
2026-03-17 18:07:15 +00:00
Sameer Kankute
1b91e1656a Add support for gpt-5.4 mini and nano 2026-03-17 23:20:59 +05:30
rstar327
b0db75df1f
fix(proxy): convert max_budget to float when set from environment variable (#23855)
Fixes #23843
2026-03-17 23:05:07 +05:30
ryan-crabbe
ef9cc33ee3
Merge pull request #23822 from BerriAI/litellm_ryan_march_16
Litellm ryan's daily branch march 16
2026-03-17 10:03:01 -07:00
yuneng-jiang
a622a1fa35
Merge pull request #23827 from BerriAI/litellm_internal_dev_03_16_2026
[Infra] Merge daily dev branch with main
2026-03-17 09:58:06 -07:00
cohml
3eeb14bf1a
fix(cache): Fix Redis cluster caching (#23480)
* fix redis cluster startup_nodes check order

* add tests for redis cluster startup_nodes fix
2026-03-17 08:32:01 -07:00
d
32ecd24116 fix: address P2 review feedback - exception handling and warning accuracy
- Add try/except around _initialize_shared_aiohttp_session call to catch
  and log exceptions (instead of letting them bubble to outer handler)
- Fix warning message when re-checked session is None (was incorrectly
  logging closed session ID on a None session)
- Add debug logging to outer except handler instead of bare pass
- Add test for _initialize_shared_aiohttp_session raising exception
2026-03-17 13:09:26 +00:00
Sameer Kankute
8eb8756e84 fix: Preserve annotations in Azure AI Foundry Agents responses
Azure AI Agents with Grounding (e.g., Bing Search) include annotations
(citation URLs) in responses, but the handler was dropping them during
transformation. This fix:

- Extracts annotations from text content in agent responses
- Transforms them to OpenAI-compatible ChatCompletionAnnotation format
- Passes annotations through all completion paths (sync, async, streaming)
- Handles both polling and SSE streaming responses

Fixes #19126

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-17 15:55:41 +05:30
Sameer Kankute
5692db8123 fix(file_search): address latest greptile feedback
Strip internal logging ids from emulated sub-calls, dedupe included search_results by file_id, clean unused imports, and add unit coverage for dedupe behavior.

Made-with: Cursor
2026-03-17 15:33:11 +05:30
d 🔹
9e09bbc1df fix: reset _shared_session_lock in all tests for event loop isolation
Address Greptile P1 review: tests that exercise the closed-session code
path need to reset the module-level lock to avoid RuntimeError on
Python < 3.10 when asyncio.Lock is reused across different event loops.
2026-03-17 09:54:01 +00:00
Sameer Kankute
729f7d48eb fix(file_search): address greptile review on follow-up calls and tests
Include all function_call items when building emulated follow-up input and update tests to assert real emulated routing + Responses-format function tool structure.

Made-with: Cursor
2026-03-17 15:10:46 +05:30
voidborne-d
ab4fda2eeb fix: add asyncio.Lock to prevent session/connector leak on concurrent recreation
When multiple requests detect a closed shared session simultaneously,
they would each create a new aiohttp.ClientSession, leaking intermediate
sessions and their TCP connectors. Added double-checked locking pattern
with asyncio.Lock to ensure only one coroutine recreates the session.

Added concurrent recreation test case.
2026-03-17 08:08:44 +00:00
yuneng-jiang
dcbaa0512b
Merge pull request #23826 from BerriAI/litellm_yj_march_16_2026
[Infra] Merge personal dev branch with daily dev branch
2026-03-16 23:47:50 -07:00
Sameer Kankute
c735251570 feat(responses): file_search support — Phase 1 native passthrough + Phase 2 emulated fallback
Phase 1 (native passthrough):
- _decode_vector_store_ids_in_tools(): decode LiteLLM-managed unified
  vector_store_ids to provider-native IDs in file_search tools
- Split update_responses_tools_with_model_file_ids() into decode pass
  (always runs) + code_interpreter mapping pass (guarded)
- BaseResponsesAPIConfig.supports_native_file_search() → False by default;
  OpenAIResponsesAPIConfig overrides to True
- ManagedFiles.async_pre_call_hook(): batch team-level access check for
  unified vector_store_ids in file_search tools (no N+1)
- Docs: file_search section in response_api.md

Phase 2 (emulated fallback for non-native providers):
- litellm/responses/file_search/emulated_handler.py: converts file_search
  tool → function tool, intercepts tool call, runs asearch(), makes
  follow-up call, synthesizes OpenAI-format output (file_search_call +
  message + file_citation annotations)
- responses/main.py: routes to emulated handler when provider doesn't
  support file_search natively

Tests: 41 unit tests across 8 families (A-H) in test_file_search_responses.py

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 11:41:44 +05:30