fix(gemini): keep the 2048 cache minimum on Gemini 2.5 Pro only, per Google's live cachedContents API

This commit is contained in:
mateo-berri 2026-09-19 00:07:22 -07:00
parent 3289e22834
commit 2303379c20
3 changed files with 6 additions and 9 deletions

View file

@ -25066,7 +25066,6 @@
"supports_parallel_function_calling": true,
"supports_pdf_input": true,
"supports_prompt_caching": true,
"prompt_cache_min_tokens": 2048,
"supports_reasoning": true,
"supports_response_schema": true,
"supports_system_messages": true,
@ -27139,7 +27138,6 @@
"supports_parallel_function_calling": true,
"supports_pdf_input": true,
"supports_prompt_caching": true,
"prompt_cache_min_tokens": 2048,
"supports_reasoning": true,
"supports_response_schema": true,
"supports_system_messages": true,

View file

@ -25066,7 +25066,6 @@
"supports_parallel_function_calling": true,
"supports_pdf_input": true,
"supports_prompt_caching": true,
"prompt_cache_min_tokens": 2048,
"supports_reasoning": true,
"supports_response_schema": true,
"supports_system_messages": true,
@ -27139,7 +27138,6 @@
"supports_parallel_function_calling": true,
"supports_pdf_input": true,
"supports_prompt_caching": true,
"prompt_cache_min_tokens": 2048,
"supports_reasoning": true,
"supports_response_schema": true,
"supports_system_messages": true,

View file

@ -1396,14 +1396,15 @@ class TestContextCachingEndpoints:
# Restart the patcher so teardown_method can stop it cleanly
self._token_check_patcher.start()
@pytest.mark.parametrize("model", ["gemini-2.5-flash", "gemini-2.5-pro"])
def test_check_and_create_cache_skips_between_default_and_gemini_2_5_minimum(
self, model, local_model_cost_map
def test_check_and_create_cache_skips_between_default_and_gemini_2_5_pro_minimum(
self, local_model_cost_map
):
"""Gemini 2.5 Flash and Pro need 2048 cached tokens, twice the provider-agnostic default.
"""Gemini 2.5 Pro needs 2048 cached tokens, twice the provider-agnostic default.
Content between the two used to reach Google's cachedContents endpoint and 400.
Content between the two used to reach Google's cachedContents endpoint and 400
with "Cached content is too small".
"""
model = "gemini-2.5-pro"
self._token_check_patcher.stop()
cached_messages = [