Ollama's prompt_eval_count may exclude KV-cached tokens (system
prompt, prior conversation turns), under-counting the prompt size
used for cost/FLOPs/energy calculations and leaderboard submissions.
Engine changes:
- Add estimate_prompt_tokens() helper in engine/_base.py that
computes cache-agnostic token count from message content
- Ollama + OpenAI-compat engines now use max(reported, estimated)
to ensure system prompt and full context are always counted
Savings/leaderboard changes:
- Add TOKEN_COUNTING_VERSION=2 to savings.py so frontends can
tag Supabase submissions (old=v1, corrected=v2)
- Desktop + web frontends forward version in leaderboard submissions
- Add POST /v1/telemetry/reset endpoint to clear stale telemetry
Active users auto-correct via upsert on next session; no manual
Supabase migration required.