Skip to content

fix: unify cost tracking with 3-tier pricing resolution - #79

Merged
DeveshParagiri merged 1 commit into
mainfrom
fix/unified-cost-tracking
Feb 17, 2026
Merged

DeveshParagiri merged 1 commit into
mainfrom
fix/unified-cost-tracking

Conversation

@RandomOscillations

Copy link
Copy Markdown
Collaborator

Summary

  • Delete legacy extropy/core/pricing.py (hardcoded-only dict) and redirect all imports to extropy/core/cost/pricing.py (OpenRouter API → 24h cache → hardcoded fallback)
  • Tag every LLM-using CLI command with CostTracker.set_context(command=...) so ledger entries are labeled
  • Show per-model cost breakdown in summary_line() when multiple models are used (previously collapsed to "2 models")
  • Update estimate command from scenario.yaml --study-db study.db to -s/--scenario with study context pattern, consistent with simulate/results/etc
  • Pre-warm pricing cache eagerly in main_callback() when --cost or show_cost config is enabled

Test plan

  • 812 tests pass (pytest --tb=short -q)
  • ruff check . && ruff format --check . clean
  • Verified old extropy.core.pricing import raises ModuleNotFoundError
  • Verified 3-tier pricing resolves 311 models from OpenRouter cache
  • Verified summary_line() multi-model output: $0.29 — gpt-5: $0.26 (...) · gpt-5-mini: $0.03 (...)
  • Verified estimate -s extended works end-to-end with test study folder

Closes #77

🤖 Generated with Claude Code

Delete legacy extropy/core/pricing.py (hardcoded-only) and redirect all
imports to extropy/core/cost/pricing.py which resolves prices via
OpenRouter API → 24h cache → hardcoded fallback. This ensures --cost
footer and estimate command use fresh prices for 300+ models.

- Tag every CLI command with CostTracker.set_context() for ledger entries
- Show per-model cost breakdown in summary_line() when multiple models used
- Update estimate command to use -s/--scenario with study context pattern
- Pre-warm pricing cache eagerly when cost tracking is enabled

Closes #77

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@DeveshParagiri
DeveshParagiri merged commit 5b2d294 into main Feb 17, 2026
4 of 5 checks passed
@DeveshParagiri
DeveshParagiri deleted the fix/unified-cost-tracking branch February 17, 2026 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unified cost tracking: estimate + --cost with live pricing data

2 participants