Repository navigation
Description
Summary
Found in the release/v0.2.23 review (line numbers at 7fdaa9d).
-
Tiered models are overpriced by 1.5 to 2x. Per-million rates come from a fake usage of 1M input and 1M output tokens (
src/devops_cli/ai/spend/pricing.py:103, and again at:240in_build_catalog). That usage crosses genai-prices' long-context tiers, so every call is recorded at >200K-token prices. Reproduced with the pinned genai-prices:Model Recorded (1M/1M tier) Correct for a 20K/2K call claude-sonnet-4-5 $6.00 / $22.50 $3.00 / $15.00 gemini-2.5-pro $2.50 / $15.00 $1.25 / $10.00 36 of 1,593 models are affected. The overstated costs flow into
spend.db,list-pricing, benchmarkmedian_cost_usdand counterfactuals. -
Prices depend on the time of the lookup, not the time of the request.
calc_priceis called withoutgenai_request_timestamp. Time-windowed prices such as DeepSeek's off-peak rate follow the clock at lookup.tests/test_ai_spend_pricing.py:36fails for half of every day. It expects0.135(off-peak) but gets0.27between 00:30 and 16:30 UTC.- Its expected value has already been flipped twice to match the clock (
3c715df, and again on the branch of feat(k8s): consolidate llm profiles by vram, bypass squid for rfc1918/local, add gemma4:31b #654).
-
devops ai cost update-pricinghas no lasting effect. It only swaps genai-prices' in-memory snapshot (pricing.py:266-283,src/devops_cli/commands/ai_cost.py:566-594). Nothing is saved, and later commands use the bundled snapshot again.--source <path>fails, although the help text promises "URL or file path". -
Price overrides depend on the working directory.
PricingRegistryresolvessettings.data.diragainst the current directory (pricing.py:134-140), while the ledger now usesresolve_data_path. Overrides set from a subdirectory or a linked worktree are invisible to reviews run elsewhere. -
cost roi --days Nunderstates the daily rate. It divides by N even when only part of the window has data (src/devops_cli/ai/spend/payoff.py:14-15). -
The
--daysfilters include an extra day. They compare ISO timestamps (...T...+00:00) as text against SQLitedatetime('now')(YYYY-MM-DD HH:MM:SS) (src/devops_cli/ai/spend/ledger.py:80,:98,:114,:129,:142,:157). This existed onmain, but the new queries copy it. -
The column migration can race (unconfirmed). The
served_by/stagemigration checks for the columns, then runsALTERoutside a transaction (ledger.py:229-233). Two processes opening an oldspend.dbcan race. The second fails with "duplicate column name", which can re-send an LLM call that already succeeded. -
--format prometheusignores the report options. It drops--days,--reference-modeland--hardware-cost(ai_cost.py:340-344,:415-419;prometheus.py:133).
Remediation Plan
- Price each call from its real usage and request time with
calc_price(usage, model, genai_request_timestamp=...). Where per-million rates are displayed, derive them from a representative small usage and label them as such. - Pin a timestamp in the pricing tests, so they no longer depend on the clock.
- Persist fetched snapshots under the data directory and load them at startup. Support a file path for
--source. - Resolve pricing overrides through
resolve_data_path. - Divide by the observed span when it is shorter than
--days. - Compare timestamps in one format.
- Make the migration idempotent under concurrency: run it in a transaction and tolerate "duplicate column" errors.
- Pass the report options through to the Prometheus exporter.
- Add tests for each item.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix: harden sandbox, pricing ledger, cloudflare public IP bypass, and…
dan-petty commentedon Sep 28, 2026
Closed by #676, merged into
release/v0.2.23.GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by
devops gh issues close-merged.