Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(cost): simplify global cost tracker internals

Steven Enamakel7a7515b76cb3
diff --git a/crates/openhuman-core/src/platform/cost/global.rs b/crates/openhuman-core/src/platform/cost/global.rs
index 798ca791c9..9427f8305a 100644
--- a/crates/openhuman-core/src/platform/cost/global.rs
+++ b/crates/openhuman-core/src/platform/cost/global.rs
@@ -235,9 +235,13 @@ pub(super) fn build_token_usage(model: &str, usage: &BilledUsage) -> Option<Toke
return None;
}
let total_tokens = usage.input_tokens.saturating_add(usage.output_tokens);
- let provider_charged = !usage.cost_is_estimate
- && usage.charged_amount_usd.is_finite()
- && usage.charged_amount_usd > 0.0;
+ let cost_source = if usage.cost_is_estimate {
+ CostSource::Estimated
+ } else if usage.charge_reported {
+ CostSource::ProviderCharged
+ } else {
+ CostSource::Unknown
+ };
Some(TokenUsage {
model: model.to_string(),
input_tokens: usage.input_tokens,