Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix: mark test_caching_with_reasoning_content as flaky and handle InternalServerError (#17603)

Alexsander Hamir09dcd381d78e
diff --git a/tests/local_testing/test_caching.py b/tests/local_testing/test_caching.py
index 2b2c9853db5..7fb57cef9ee 100644
--- a/tests/local_testing/test_caching.py
+++ b/tests/local_testing/test_caching.py
@@ -2634,6 +2634,7 @@ def test_redis_caching_multiple_namespaces():
), f"Expected different response ID for no namespace vs namespaced. Got {response_1.id} and {response_4.id}"
[email protected](retries=3, delay=1)
def test_caching_with_reasoning_content():
"""
Test that reasoning content is cached
@@ -2641,24 +2642,27 @@ def test_caching_with_reasoning_content():
from litellm._uuid import uuid
- messages = [{"role": "user", "content": f"what is litellm? {uuid.uuid4()}"}]
- litellm.cache = Cache()
+ try:
+ messages = [{"role": "user", "content": f"what is litellm? {uuid.uuid4()}"}]
+ litellm.cache = Cache()
- response_1 = completion(
- model="anthropic/claude-3-7-sonnet-latest",
- messages=messages,
- thinking={"type": "enabled", "budget_tokens": 1024},
- )
+ response_1 = completion(
+ model="anthropic/claude-3-7-sonnet-latest",
+ messages=messages,
+ thinking={"type": "enabled", "budget_tokens": 1024},
+ )
- response_2 = completion(
- model="anthropic/claude-3-7-sonnet-latest",
- messages=messages,
- thinking={"type": "enabled", "budget_tokens": 1024},
- )
+ response_2 = completion(
+ model="anthropic/claude-3-7-sonnet-latest",
+ messages=messages,
+ thinking={"type": "enabled", "budget_tokens": 1024},
+ )
- print(f"response 2: {response_2.model_dump_json(indent=4)}")
- assert response_2._hidden_params["cache_hit"] == True
- assert response_2.choices[0].message.reasoning_content is not None
+ print(f"response 2: {response_2.model_dump_json(indent=4)}")
+ assert response_2._hidden_params["cache_hit"] == True
+ assert response_2.choices[0].message.reasoning_content is not None
+ except litellm.InternalServerError as e:
+ pytest.skip(f"Anthropic API returned InternalServerError - {str(e)}")
def test_caching_reasoning_args_miss(): # test in memory cache