Skip to content

False free→paid alert: zero-token calls with explicitly-priced models trigger known_free_models #89

Description

@nujovich

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

  1. Have deepseek/deepseek-v4-pro in pricing.yaml at a non-zero price
  2. A call with 0 tokens goes through (e.g. model selection, startup)
  3. known_free_models gets a row: (deepseek/deepseek-v4-pro, nous)
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions