Make Rust cost reporting aware of the active model

This replaces the single default pricing assumption with a small model-aware pricing table for Sonnet, Opus, and Haiku so CLI usage output better matches the selected model. Unknown models still fall back cleanly with explicit labeling.

The change keeps pricing lightweight and local while improving the usefulness of usage/cost reporting for resumed sessions and live turns.

Constraint: Keep pricing local and dependency-free

Constraint: Preserve graceful fallback behavior for unknown model IDs

Rejected: Add a remote pricing source now | unnecessary coupling and risk for this slice

Confidence: high

Scope-risk: narrow

Reversibility: clean

Directive: If pricing tables expand later, prefer explicit model-family matching and keep fallback labeling visible

Tested: cargo fmt; cargo clippy --all-targets --all-features -- -D warnings; cargo test -q

Not-tested: Validation against live provider billing exports
This commit is contained in:
Yeachan-Heo
2026-03-31 19:42:31 +00:00
parent add5513ac5
commit 6fe404329d
3 changed files with 117 additions and 12 deletions

View File

@@ -38,4 +38,6 @@ pub use prompt::{
SystemPromptBuilder, FRONTIER_MODEL_NAME, SYSTEM_PROMPT_DYNAMIC_BOUNDARY,
};
pub use session::{ContentBlock, ConversationMessage, MessageRole, Session, SessionError};
pub use usage::{format_usd, TokenUsage, UsageCostEstimate, UsageTracker};
pub use usage::{
format_usd, pricing_for_model, ModelPricing, TokenUsage, UsageCostEstimate, UsageTracker,
};