mirror of
https://github.com/lWolvesl/claw-code.git
synced 2026-04-03 02:31:51 +08:00
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:
@@ -386,6 +386,9 @@ fn inspect_session(target: &str) {
|
||||
println!("- size_bytes: {bytes}");
|
||||
println!("- messages: {}", session.messages.len());
|
||||
println!("- total_tokens: {}", usage.total_tokens());
|
||||
for line in usage.summary_lines_for_model("- usage", None) {
|
||||
println!("{line}");
|
||||
}
|
||||
println!("- preview: {}", session_preview(&session));
|
||||
|
||||
if let Some(user_text) = latest_text_for_role(&session, MessageRole::User) {
|
||||
@@ -499,7 +502,7 @@ impl LiveCli {
|
||||
self.runtime.usage().turns(),
|
||||
self.runtime.estimated_tokens()
|
||||
);
|
||||
for line in usage.summary_lines("usage") {
|
||||
for line in usage.summary_lines_for_model("usage", Some(&self.model)) {
|
||||
println!("{line}");
|
||||
}
|
||||
}
|
||||
@@ -507,11 +510,11 @@ impl LiveCli {
|
||||
fn print_turn_usage(&self, cumulative_usage: TokenUsage) {
|
||||
let latest = self.runtime.usage().current_turn_usage();
|
||||
println!("\nTurn usage:");
|
||||
for line in latest.summary_lines(" latest") {
|
||||
for line in latest.summary_lines_for_model(" latest", Some(&self.model)) {
|
||||
println!("{line}");
|
||||
}
|
||||
println!("Cumulative usage:");
|
||||
for line in cumulative_usage.summary_lines(" total") {
|
||||
for line in cumulative_usage.summary_lines_for_model(" total", Some(&self.model)) {
|
||||
println!("{line}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user