Repository navigation
Conversation
- The supervisor reads the OpenRouter balance only after resume validation, so a refused resume makes no request (#305). - A response with prompt tokens, zero completion tokens and no provider cost now records 0 completion tokens and gets a reconstructed cost (#305). - The analysis cost fallback prices cache reads and writes at the override's own rates, through the same function as reconstruction (#305). - The supervisor's spend meter falls back to PRICE_OVERRIDES_PER_1M for a model with recorded tokens and no recorded cost, so --budget-usd binds for override-priced models (#129). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The leaderboard's price-override fallback goes back to main's aggregate expression (prompt * input / 1e6 + completion * output / 1e6) unless the model has cache tokens priced at a rate other than the input rate. Only then does it cap cache reads and writes per row and price the summed classes with per_request=False. The frozen 20260501 snapshot values reproduce exactly again. Usage extraction prices the same completion count it records. A response that reports zero completion tokens now gets a reconstructed input cost even when the provider also reports a charge, the same precedence every other response already follows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round 1 found two ways the budget governor's disk fallback could misstate spend. One recorded cost anywhere in a model's files suppressed the price override estimate for every other call, so an unpriced live call beside a $0 cache replay metered $0. _spent_from_disk now applies recorded-cost precedence per ledger call and per CSV row, genuine zeros included. A scenario's spend ledger, when it yields any cost, covers that scenario and its CSV is skipped, so the same usage is never counted twice. The CSV estimate priced every row with nonzero live_calls, including rows that mix live calls and cache replays, and rows whose live_calls is blank or absent. An unpriced CSV row is now estimated only when live_calls > 0 and cache_hit_calls == 0. Mixed groups rely on the ledger. Tests: the recorded-cost test puts a priceable unpriced row beside a recorded $0 or $0.70 row, in one CSV and across two. New tests price only the unrecorded ledger calls and cover zero, blank, missing and mixed CSV provenance. The governor fixtures carry known live provenance. The exact-equality cost test now runs the second row at six and four completion tokens, which between them distinguish both summation orders for both models. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #305 and #129.
What changes
Supervisor.__init__no longer calls the OpenRouter/creditsendpoint.run()reads the baseline after_validate_resumeand the provenance write, so a refused resume never calls OpenRouter's/creditsendpoint. (Importing LiteLLM can still fetch its cost map, as it does on main.)_spent()only reads the credits fields when a baseline exists, so moving the setup is safe.eval_no_toolsusedcompletion_tokens or output_tokens, which turned a reported 0 into missing and skipped cost reconstruction for the prompt side. It now keeps 0 and prices the count it records. A zero-output response gets a reconstructed input cost even when the provider also reports a charge, the same precedence every other response already follows (reconstructed cost first, provider cost only when reconstruction is impossible).gpt_responses_cache_rates,bounded_cache_tokens,override_token_costandoverride_cost_for_usagemove toconfig.py, andeval_no_toolsreconstruction calls them.analysis.model_cost_latencykeeps main's aggregate expression (prompt * input / 1e6 + completion * output / 1e6) unless a model has cache tokens priced at a rate other than its input rate. Only then does it cap cache reads and writes per row and price the summed classes at the override's cache rates._spent_from_diskestimates spend fromPRICE_OVERRIDES_PER_1Mfor calls with recorded tokens and no recorded cost, so--budget-usdnow binds for override-priced models instead of reading $0. Recorded costs, genuine zeros included, take precedence per ledger call and per CSV row, so one recorded cost no longer hides other calls' usage. A scenario's spend ledger, when it yields any cost, covers that scenario, and its CSV is skipped so the same usage is never counted twice. An unpriced CSV row is estimated only when it shows live calls and no cache replays (live_calls > 0,cache_hit_calls == 0). Rows that mix the two rely on the ledger.Impact on published numbers
model_cost_latencyfeeds the dashboard export'scostUsd. I ran main's and this head'smodel_cost_latencyon the frozen US snapshot (paper/snapshot/20260501/runs/us_full_run_20260612_policyengine_4_16_1_populace/predictions.csv.gz), once with every column and once without the cache columns. Every model'scostUsd,costPerHouseholdand latency fields are identical, bit for bit. Three override-priced models there have no recorded cost:claude-fable-5(no recorded usage, so no cost either way),gemini-3.6-flash(no cache tokens) andgrok-build-0.1(132,096 cache reads, but its override has no separate cache rate). All three take main's aggregate branch.The fix commit that reworked the budget meter touched only
supervisor.pyand tests, not the export path, so this comparison still applies.Existing rows change on re-export only for a model with no recorded
total_cost_usdwhose cache tokens price at a rate other than its input rate, including GPT models whose cache rates are implicit.Future runs record cost differently in two cases, for any model with a known price:
total_cost_usdand the charge stays inprovider_reported_cost_usd.Both apply to cache replays processed after this change as well as to live calls, and both feed
costUsdandcostPerHousehold, even for models with a single input rate. Under the PR guide this is a bug fix that moves model aggregates, so it states the impact here rather than asking for approval.Overlap
#300 (held) edits four of the same files (
config.py,eval_no_tools.py,supervisor.pyandtests/test_eval_no_tools.py), for OpenRouter routing rather than cost. Whichever merges second may need a rebase.Tests
test_supervisor:test_refused_openrouter_resume_never_requests_credits;test_budget_governor_prices_unrecorded_cost_with_override(ledger and CSV arms, both with known live provenance);test_spend_override_preserves_recorded_csv_cost(a recorded $0 or $0.70 row beside an unpriced row, in one CSV and across two);test_spend_override_prices_only_unrecorded_ledger_calls;test_spend_override_requires_live_only_csv_provenance(zero, blank, missing and mixed provenance). Existing baseline tests now callrun()before they check the baseline.test_eval_no_tools:test_zero_completion_tokens_still_reconstructs_input_costexpects the reconstructed input cost with and without a provider charge.test_cost_latency:test_price_override_uses_cache_read_and_write_rates;test_price_override_at_input_rate_matches_aggregate_cost(exact equality with main's expression forgemini-3.6-flashandgrok-build-0.1, with the second row at six and at four completion tokens, which between them catch both a per-row sum andoverride_token_coston the totals);test_price_override_bounds_cache_counts_per_row.test_anthropic_thinking_tokens: completion tokens equal the batch's;test_a_response_with_no_output_tokens_records_zero_completion.The patch and its fix commits came from read-only Codex lanes that could not run pytest. CI runs the tests (
-m "not slow").ruff checkandruff format --checkpass on the changed files.🤖 Generated with Claude Code