Skip to content

fix: price gain estimates from resolved model - #1244

Merged
yvgude merged 1 commit into
yvgude:mainfrom
malochapo:fix/gain-cost-model-pricing
Jul 27, 2026
Merged

fix: price gain estimates from resolved model#1244
yvgude merged 1 commit into
yvgude:mainfrom
malochapo:fix/gain-cost-model-pricing

Conversation

@malochapo

Copy link
Copy Markdown
Contributor

Summary

Fixes #1243.

lean-ctx gain --deep now prices cost estimates from the best available model signal instead of falling straight back to blended pricing when env vars are absent.

This PR:

  • carries the resolved model_key and pricing match kind through CostModel
  • resolves gain pricing from env/config/proxy dominant model before fallback
  • shows the resolved model and whether the price is exact/live/estimated/fallback in the cost breakdown
  • makes usd_estimate reuse the same CostModel pricing path

Test plan

  • cd rust && cargo test --lib pricing -- --nocapture
  • cd rust && cargo fmt --check
  • cd rust && cargo clippy --all-features -- -D warnings
  • cd rust && cargo test -- --test-threads=1 (the suite shares process-global state; CI serializes it too)

Notes for reviewers

  • Risk areas / edge cases: StatsStore remains aggregate, so this improves the dashboard estimate using the best current model signal; it does not reconstruct exact historical per-call model costs.
  • Backwards compatibility: fallback blended pricing remains the final fallback when no model signal exists.
  • Docs updated (links/files): no docs file changed; the cost breakdown label now surfaces the pricing source.

Contributor License Agreement

First-time contributors: a bot will ask you to sign our one-time CLA.

@yvgude
yvgude merged commit 8ed8d5d into yvgude:main Jul 27, 2026
25 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: gain cost estimate falls back to blended pricing instead of resolved model

2 participants