fix(cost): read litellm.model_cost once in _model_has_known_pricing

The cost-map reload path can swap the litellm.model_cost dict between
loop iterations; binding it to a local first makes both key lookups
observe the same snapshot
This commit is contained in:
Filippo Mattia Menghi 2026-06-10 10:58:58 +02:00
parent 0b89c8f079
commit 1eb49115cf

View file

@ -1097,8 +1097,9 @@ def _model_has_known_pricing(model: str, custom_llm_provider: str) -> bool:
pricing dimensions checked here); registration is only needed so unknown
models can be priced at all.
"""
model_cost_map = litellm.model_cost
for key in (model, f"{custom_llm_provider}/{model}"):
entry = litellm.model_cost.get(key)
entry = model_cost_map.get(key)
if entry is not None and (
entry.get("input_cost_per_token") is not None
or entry.get("input_cost_per_second") is not None