litellm/tests/unit/llms/vertex_ai/context_caching/conftest.py
Ondra Zahradnik 06e3e32c88
fix(vertex_ai): reuse known context caches instead of listing on every request (#46857)
Vertex AI and Gemini context caching now remember each cache they create or find until 10s before its expireTime, so a repeat cache-marked request goes straight to generateContent instead of listing every cachedContents first. Concurrent async requests for one prefix share one lookup or create

When generation rejects a remembered cache with a 400, 403 or 404 that names the cached content, the request rebuilds the cache and sends once more. Any other 400, 403 or 404 drops the record without a retry

Fixes #36395
2026-10-20 11:37:46 +00:00

10 lines
257 B
Python

import pytest
from litellm.llms.vertex_ai.context_caching.known_cached_contents import known_cached_contents
@pytest.fixture(autouse=True)
def _forget_known_cached_contents():
known_cached_contents.clear()
yield
known_cached_contents.clear()