Commit graph

961 commits

Author SHA1 Message Date
Ryan Crabbe
9e1d83e3de fix: make LITELLM_CLIENT_SPECIFIC_PARAMS a tuple to prevent TypeError
tuple + list raises TypeError in get_openai_client_cache_key. Also add
test coverage for get_openai_client_cache_key to catch type mismatches.
2026-02-21 13:25:23 -08:00
Ryan Crabbe
bbbec23c8b fix: update tests to match tuple return type for cached init params 2026-02-21 13:18:03 -08:00
ryan-crabbe
da8f038178
Merge pull request #20789 from ryan-crabbe/perf/cache-openai-init-params
perf: pre-compute OpenAI client __init__ params at module load
2026-02-21 12:47:54 -08:00
Ishaan Jaffer
0b69c21eca Revert "fix(http_handler): bypass cache when shared_session is provided for aiohttp tracing (#20630)"
This reverts commit 7ee36c2a3a.
2026-02-21 12:27:46 -08:00
michelligabriele
a395a25705
fix(cost-calc): use per-image pricing for Bedrock multimodal embeddings (#21646)
Bedrock multimodal embedding models (Titan and Nova) were being costed
using the per-token text rate instead of the correct flat per-image rate
($0.00006/image). The pricing data was correct but never applied because
image_count was never populated in prompt_tokens_details.

Pass batch_data to Titan/Nova response transformers so they can count
image inputs and set PromptTokensDetailsWrapper(image_count=N) on Usage,
mirroring the existing Vertex AI pattern from PR #9623. Also fix the
text_tokens fallback in generic_cost_per_token to not override
text_tokens=0 when image_count > 0 (image-only requests).
2026-02-20 08:51:21 -08:00
Julio Quinteros Pro
87577eb05c fix(tests): correct medium reasoning_effort assertion for gemini-3-pro-preview
For gemini-3-pro-preview (not gemini-3-flash or gemini-3.1-pro-preview),
reasoning_effort="medium" maps to thinkingLevel="high" because the "medium"
thinking level is not available on that model variant.

Both test_reasoning_effort_maps_to_thinking_level_gemini_3 and
test_reasoning_effort_dict_format_gemini_3 had the correct comment
("medium -> high") but the wrong assertion (== "medium"). Fixed to
match the production code and the comments.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 12:09:26 -03:00
Julio Quinteros Pro
963e0eabcb fix(tests): update test_max_effort_rejected_for_opus_45 regex to match new error message
The production error message was expanded when Sonnet 4.6 was also added as
a supported model for effort='max'. The test's match regex still referenced
the old "Claude Opus 4.6"-only message; update it to match the new
"Claude 4.6 models" wording.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 11:07:52 -03:00
Sameer Kankute
9e0bd46c28
Merge pull request #21659 from BerriAI/litellm_fix_converse_disable_tool
Fix mapping of parallel_tool_calls for bedrock converse
2026-02-20 18:16:10 +05:30
Sameer Kankute
b579f56ca3 Fix mapping of parallel_tool_calls for bedrock converse 2026-02-20 12:27:41 +05:30
Sameer Kankute
cdb4917185 Fix: api_base is required. Unable to determine the correct api_base for the request 2026-02-20 12:09:25 +05:30
Sameer Kankute
fb75a7130f
Merge pull request #21630 from Chesars/fix/empty-system-message-anthropic
fix(anthropic): empty system messages in translate_system_message
2026-02-20 09:32:50 +05:30
Sameer Kankute
b405f64688
Merge pull request #21598 from jtsaw/fix/anthropic-sonnet-4-6-reasoning-effort
support reasoning and effort parameters on sonnet 4.6
2026-02-20 08:24:29 +05:30
Chesars
56386969b5 fix(anthropic): remove empty system messages from message list
Empty system messages were skipped for Anthropic's system param but
not removed from the messages list, causing BadRequestError when
anthropic_messages_pt encountered the unsupported "system" role.

Fixes #21622
2026-02-19 21:46:17 -03:00
jtsaw
b28ec1c75e support reasoning + effort on sonnet 4.6 2026-02-19 11:54:55 -08:00
michelligabriele
16cfdccc7b
fix(bedrock): add Accept header for AgentCore MCP server requests (#21551)
AgentCore MCP server endpoints require the Accept header to contain
both application/json and text/event-stream per the MCP specification
(Streamable HTTP transport). Without this header, requests are rejected
with a 406 Not Acceptable error (JSON-RPC code -32011).

Sets the Accept header at the top of sign_request() so both JWT/Bearer
and SigV4 authentication paths include it.
2026-02-19 11:35:14 -08:00
Sameer Kankute
9f66a4c122 Fix test_reasoning_effort_dict_format_gemini_3 2026-02-19 22:14:20 +05:30
Sameer Kankute
647e5237a7
Merge pull request #21555 from BerriAI/litellm_server_side_compaction_trans
[Feat] Add server side compaction translation from openai to anthropic
2026-02-19 19:14:37 +05:30
Sameer Kankute
308cdb2720
Merge pull request #21557 from SherifWaly/sherif.waly/add-reasoning-multi-turn-hosted-vllm
Convert thinking_blocks to content blocks for hosted_vllm multi-turn
2026-02-19 18:56:09 +05:30
sherif.waly
5774c845d8 Convert thinking_blocks to content blocks for hosted_vllm multi-turn
For multi-turn conversations, convert thinking_blocks on assistant
messages into content blocks prepended before the rest of the content,
so reasoning context is passed back to the hosted_vllm API.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-19 12:25:18 +00:00
Sameer Kankute
a52fc738af Add server side compaction translation from openai to anthropic 2026-02-19 16:44:35 +05:30
ZeroAurora
64c916b37b fix: remove list-to-str transformation from dashscope 2026-02-19 07:30:13 +00:00
Julio Quinteros Pro
419151dce8 fix(tests): resolve merge conflict in test_vertex_ai_rerank_transformation.py
The file had two unresolved git merge conflict markers from a merge of
litellm_oss_staging_02_17_2026 into main, causing a SyntaxError when
pytest tried to collect the test module.

Kept the instance-level mocking approach (from litellm_oss_staging) for
test_get_complete_url and test_validate_environment, which is consistent
with the rest of the file and avoids class-reference issues caused by
importlib.reload(litellm) in conftest.py.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-18 11:31:56 -03:00
Sameer Kankute
3e0a72307c
Merge pull request #21474 from BerriAI/litellm_incident_report_vllm
Incident Report: vLLM Embeddings Broken by encoding_format Parameter
2026-02-18 18:43:11 +05:30
Sameer Kankute
ee3ad3aec4
Merge pull request #21464 from BerriAI/litellm_sanitise_anthropic_mesages_2
Litellm sanitise anthropic mesages 2
2026-02-18 18:39:11 +05:30
Sameer Kankute
d7401965cb
Merge pull request #21468 from BerriAI/litellm_vllm_streaming
Add 'reasoning' field to 'reasoning_content' field in delta
2026-02-18 18:35:28 +05:30
Sameer Kankute
421b4e05b3
Merge pull request #21465 from BerriAI/litellm_map_anthropi_web_search_to_chat
Add mapping for websearch from v1/messages to chat/completions
2026-02-18 18:22:28 +05:30
Sameer Kankute
a9b7320b53 Incident Report: vLLM Embeddings Broken by encoding_format Parameter 2026-02-18 18:19:02 +05:30
Sameer Kankute
aa255c7e63
Merge pull request #21361 from BerriAI/litellm_oss_staging_02_17_2026
Litellm oss staging 02 17 2026
2026-02-18 17:48:15 +05:30
Sameer Kankute
bd0c80406f
Merge pull request #21326 from BerriAI/litellm_oss_staging_02_16_2026
Litellm oss staging 02 16 2026
2026-02-18 17:47:57 +05:30
Sameer Kankute
eb8b991260
Merge branch 'main' into litellm_oss_staging_02_17_2026 2026-02-18 17:26:33 +05:30
Sameer Kankute
0e79326c81 Fix cicd tests 2026-02-18 17:25:28 +05:30
Julio Quinteros Pro
d44d52f1e3 fix(test): correct assertion order in test_case_a_orphaned_tool_call_multiple
The implementation correctly preserves tool_call order: existing results first
(call_1), then dummy results for missing ones (call_2). The test was asserting
the reverse order with incorrect comments. Fix the assertions to match the
actual correct behavior.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-18 08:25:33 -03:00
Sameer Kankute
9678c723b0 Add reasoning' field to 'reasoning_content' field in delta 2026-02-18 16:47:05 +05:30
Sameer Kankute
6b26b47cd4 Add mapping for websearch from v1/messages to chat/completions 2026-02-18 13:32:25 +05:30
Sameer Kankute
9a3c0dcb90 Add sanititzation for anthropic messages 2026-02-18 12:44:48 +05:30
Tomu Hirata
020d769930 Address Greptile review: fix SDK auth fallback and remove unused imports
- Use custom_endpoint=False so Databricks SDK auth fallback works
  (custom_endpoint=True was blocking it). The api_base returned by
  databricks_validate_environment is discarded since get_complete_url
  builds the URL separately.
- Remove unused verbose_logger import
- Remove unused json import in tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 15:57:50 +09:00
Tomu Hirata
fe7e764846 Add native Responses API support for Databricks GPT models
Databricks supports the Responses API natively for GPT models, but litellm
was falling back to the completion transformation handler which converts
responses requests to chat completion calls, losing response schema enforcement.

This adds DatabricksResponsesAPIConfig that passes responses API requests
directly to Databricks' /responses endpoint for GPT models, while non-GPT
models (Claude, Llama, etc.) continue using the completion transformation path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 15:34:18 +09:00
Sameer Kankute
8003aa2057
Merge pull request #21358 from ryanh-ai/fix/nova-2-reasoning
fix(bedrock): broaden Nova 2 model detection to support all nova-2-* variants
2026-02-18 08:04:13 +05:30
Julio Quinteros Pro
77f315eb11 fix: address Greptile review feedback for test isolation
- test_pillar_guardrails.py: Fix fixture to properly update module-level
  litellm reference using global keyword and assignment from reload
- test_anthropic_experimental_pass_through_messages_handler.py: Add missing
  assert keywords to kwargs comparison statements (lines 36, 60-62)
- test_proxy_server.py: Replace silent pytest.skip with explicit assertion
  to catch router initialization regressions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-17 21:28:23 -03:00
Julio Quinteros Pro
ab6d2eefb9 fix: improve test isolation for parallel execution
Fixes test failures that occur during parallel test execution (pytest -n 4)
due to module reloading issues with conftest.py reloading litellm.

Changes:
- Add module reload fixtures to ensure fresh references after conftest reloads
- Use patch.object and string-based patches instead of direct attribute assignment
- Use class name comparison instead of isinstance for reloaded modules
- Handle case where litellm is missing from sys.modules during parallel runs
- Move stream consumption inside patch contexts to avoid real API calls
- Mock litellm.acompletion instead of low-level HTTP handlers
- Add skipif decorator for enterprise-only test classes

Affected test files:
- test_container_integration.py
- test_responses_background_cost.py
- test_huggingface_embedding_handler.py
- test_vertex_ai_rerank_integration.py
- test_volcengine_responses_transformation.py
- test_pillar_guardrails.py
- test_litellm_pre_call_utils.py
- test_proxy_server.py
- test_converse_transformation.py
- test_chat_completions_handler.py
- test_aresponses_api_with_mcp.py
- test_anthropic_experimental_pass_through_messages_handler.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-17 21:28:23 -03:00
jquinter
faa16ef29f
Merge pull request #21428 from BerriAI/fix/vertex-gpt-oss-test-isolation
fix(tests): use class-level AsyncHTTPHandler mock in vertex GPT-OSS tests
2026-02-17 21:22:27 -03:00
Julio Quinteros Pro
ea0cfac995 fix(tests): add cache flush fixture for reliable HTTP client isolation
Add _reset_litellm_http_client_cache autouse fixture (matching
test_vertex_gemma_transformation.py) to flush in_memory_llm_clients_cache
before each test. Without this, a cached real AsyncHTTPHandler from an
earlier test could bypass the class-level mock and cause real HTTP calls.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-17 21:02:56 -03:00
Julio Quinteros Pro
f0fc44c244 fix(tests): use class-level AsyncHTTPHandler mock in vertex GPT-OSS tests
Replace instance-level patch.object(client, "post", side_effect=...) with
class-level patch of AsyncHTTPHandler and AsyncMock to reliably intercept
HTTP calls in CI where real Google credentials are available.

The old approach patched a specific instance's post method and passed
client=client to acompletion(). In CI, the mock wasn't intercepting actual
HTTP calls, causing 401 ACCESS_TOKEN_TYPE_UNSUPPORTED errors. The new
approach patches AsyncHTTPHandler at the class level so any instance
created internally by get_async_httpx_client() is also mocked.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-17 20:52:25 -03:00
Julio Quinteros Pro
a6df01caec fix: remove importlib.reload calls that cause cross-test class-reference staleness
Two test files were reloading modules in setup_method/fixtures, which
caused class-reference staleness for subsequent tests in the same worker:

1. test_huggingface_embedding_handler.py reloaded
   litellm.llms.custom_httpx.http_handler, creating a new HTTPHandler
   class. Subsequent tests (e.g. hosted_vllm embedding) created
   client = HTTPHandler() from the new class, but llm_http_handler.py
   still held the old class reference. isinstance(client, HTTPHandler)
   returned False, so a new unpatched client was used and
   client.post was never called.

2. test_vertex_ai_rerank_integration.py reloaded
   litellm.llms.vertex_ai.rerank.transformation in setup_method,
   creating a new VertexAIRerankConfig class. The transformation test
   file's module-level import still referenced the old class, so
   @patch('...VertexAIRerankConfig._ensure_access_token') patched the
   new class while self.config was an instance of the old class,
   leaving the mock unapplied and hitting real Google credentials.

Fix: remove the reload calls. The module-level class references are
stable across tests within a worker; the reloads were solving a problem
that doesn't exist and actively created cross-test contamination.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-17 20:31:10 -03:00
Julio Quinteros Pro
26f8e1ac0a fix(tests): resolve test isolation issue in http_handler tests
Fix isinstance() checks failing due to module reload in conftest.py.

The conftest.py fixture reloads the litellm module between test modules,
which causes class references imported at module-level to become stale.
When AsyncHTTPHandler is imported at the top of the file and then litellm
is reloaded by the fixture, the isinstance() check fails because the
returned instance is of the NEW AsyncHTTPHandler class while the test
is checking against the OLD class reference.

Solution: Import AsyncHTTPHandler locally within each test function that
uses isinstance() checks. This ensures we get the fresh class reference
after the module reload.

Fixed tests:
- test_session_reuse_integration
- test_get_async_httpx_client_with_shared_session
- test_get_async_httpx_client_without_shared_session

This resolves intermittent CI failures where parallel test execution
triggers the module reload behavior.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-17 19:01:02 -03:00
Sameer Kankute
809838042e
Merge pull request #21382 from BerriAI/litellm_vllm_e2e_testing
Add vllm e2e test for embedding
2026-02-17 22:32:42 +05:30
Sameer Kankute
811ffff0b8 move e2e to llm translation 2026-02-17 21:14:44 +05:30
Sameer Kankute
ec573ee2b0
Merge pull request #21375 from BerriAI/litellm_evals_api
[feat] Add support for Openai Evals API
2026-02-17 21:01:36 +05:30
Sameer Kankute
550bb621f7 fix llm tests 2026-02-17 20:13:23 +05:30
Sameer Kankute
211d6e9d30 Add vllm e2e test for embedding 2026-02-17 19:42:46 +05:30