Bug
A model with a valid price (e.g. deepseek-v4-pro at $0.348/$0.696) gets incorrectly flagged as a "free model" and later triggers a false "free→paid transition" alert.
Root cause
In __init__.py line 350-351:
if cost == 0.0 and pricing.is_explicitly_priced(effective_model, provider):
db.record_free_model(effective_model, provider)
The check only looks at the current call cost ($0.00) and whether the model has pricing (True). It does NOT check whether the model's actual pricing rates are $0/$0.
When a call with 0 input tokens and 0 output tokens happens (common at session startup or tool-only turns), cost == 0.0 is true, and the model gets inserted into known_free_models. Any subsequent call with real tokens → cost > $0 → false free→paid alert.
Reproduction
- Have
deepseek/deepseek-v4-pro in pricing.yaml at a non-zero price
- A call with 0 tokens goes through (e.g. model selection, startup)
known_free_models gets a row: (deepseek/deepseek-v4-pro, nous)
- Next real call costs > $0 → free→paid alert fires
Real data from production:
known_free_models: deepseek/deepseek-v4-pro | nous | 2026-07-27T04:02:41
llm_calls: deepseek/deepseek-v4-pro | nous | tokens_in=0, tokens_out=0, cost=0.0
free_paid_transitions: deepseek/deepseek-v4-pro | nous | first_paid=$0.0085
Suggested fix
# Only record as free if the model rates are actually $0, not just this call
if cost == 0.0 and pricing.is_explicitly_priced(effective_model, provider):
prices = pricing._resolve_pricing(effective_model, provider)
if prices and prices.get("input", -1) == 0.0 and prices.get("output", -1) == 0.0:
db.record_free_model(effective_model, provider)
This mirrors the existing logic in pricing.get_known_free_models() which correctly filters for input==0 AND output==0.
Bug
A model with a valid price (e.g.
deepseek-v4-proat $0.348/$0.696) gets incorrectly flagged as a "free model" and later triggers a false "free→paid transition" alert.Root cause
In
__init__.pyline 350-351:The check only looks at the current call cost ($0.00) and whether the model has pricing (True). It does NOT check whether the model's actual pricing rates are $0/$0.
When a call with 0 input tokens and 0 output tokens happens (common at session startup or tool-only turns),
cost == 0.0is true, and the model gets inserted intoknown_free_models. Any subsequent call with real tokens → cost > $0 → false free→paid alert.Reproduction
deepseek/deepseek-v4-proin pricing.yaml at a non-zero priceknown_free_modelsgets a row:(deepseek/deepseek-v4-pro, nous)Real data from production:
Suggested fix
This mirrors the existing logic in
pricing.get_known_free_models()which correctly filters forinput==0 AND output==0.