test(pricing): assert cache-priced vertex grok rows advertise supports_prompt_caching (#41526)

* test(pricing): lock supports_prompt_caching on cache-priced grok rows

Check the catalog field itself so a price sync cannot drop the Vertex
Grok flag while the helper still passes via the xai/ fallback. Also
cover get_model_info on the full vertex_ai/xai/grok-4.6 key and keep
the backup map in lockstep.

Co-authored-by: Techboy bebop  <kumarpriyanshu09@users.noreply.github.com>

* test(pricing): assert grok cache rows via get_model_info

The helper can still pass via the bare xai/ grok row, so lock the
catalog flag through get_model_info instead of reading the JSON files

Co-authored-by: Techboy bebop  <kumarpriyanshu09@users.noreply.github.com>

* test(pricing): assert grok cache flags via get_model_info

Address Greptile P2 by checking supports_prompt_caching through
get_model_info on full catalog keys instead of raw JSON fields, so
the check cannot pass via the bare xai/grok-* helper path. Keep
backup/primary parity for vertex_ai/xai/grok-* entries.

* test(pricing): assert grok cache flags via runtime APIs only

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Techboy bebop <kumarpriyanshu09@users.noreply.github.com>
This commit is contained in:
Techboy bebop 2026-09-21 23:58:11 -04:00 • committed by GitHub
parent 25ebb9458c
commit 571e5797d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -13,16 +13,18 @@ GROK_KEY_PREFIXES: Final = ("vertex_ai/xai/grok-", "azure_ai/grok-", "xai/grok-"
@pytest.mark.usefixtures("local_model_cost_map")
def test_grok_models_with_cache_read_price_advertise_prompt_caching() -> None:
cached_grok_models = tuple(
cached_grok_models: Final = tuple(
key
for key, entry in litellm.model_cost.items()
if key.startswith(GROK_KEY_PREFIXES) and entry.get("cache_read_input_token_cost")
)
assert cached_grok_models, "expected at least one grok model with a cache read price"
missing_flag = tuple(key for key in cached_grok_models if supports_prompt_caching(model=key) is not True)
missing_flag: Final = tuple(
key for key in cached_grok_models if get_model_info(model=key).get("supports_prompt_caching") is not True
)
assert missing_flag == (), (
f"grok models with cache_read_input_token_cost fail supports_prompt_caching: {missing_flag}"
f"grok models with cache_read_input_token_cost fail get_model_info supports_prompt_caching: {missing_flag}"
)
@ -31,8 +33,14 @@ def test_vertex_ai_grok_4_6_supports_prompt_caching_via_get_model_info() -> None
routed_model, provider, _, _ = get_llm_provider(model=MODEL)
assert (routed_model, provider) == ("xai/grok-4.6", "vertex_ai")
info = get_model_info(model=routed_model, custom_llm_provider=provider)
assert info["litellm_provider"] == "vertex_ai"
assert info.get("supports_prompt_caching") is True
routed_info: Final = get_model_info(model=routed_model, custom_llm_provider=provider)
assert routed_info["litellm_provider"] == "vertex_ai"
assert routed_info.get("supports_prompt_caching") is True
assert routed_info.get("cache_read_input_token_cost")
catalog_info: Final = get_model_info(model=MODEL)
assert catalog_info["key"] == MODEL
assert catalog_info.get("supports_prompt_caching") is True
assert catalog_info.get("cache_read_input_token_cost")
assert supports_prompt_caching(model=MODEL) is True