Skip to content

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

fix(progress_tracing): derive per-mtok pricing from per-token fields

Steven Enamakeld669abca4c79
diff --git a/crates/openhuman-core/src/agent/progress_tracing/collector/model_call.rs b/crates/openhuman-core/src/agent/progress_tracing/collector/model_call.rs
index f4dfdae7be..af0f69ab59 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/collector/model_call.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/collector/model_call.rs
@@ -243,15 +243,15 @@ impl SpanCollector {
if let Some(pricing) = pricing {
attrs.insert(
"gen_ai.pricing.input_per_mtok_usd".to_string(),
- json_f64(pricing.input_per_mtok_usd),
+ json_f64(pricing.input_per_token.unwrap_or(0.0) * 1_000_000.0),
);
attrs.insert(
"gen_ai.pricing.cached_input_per_mtok_usd".to_string(),
- json_f64(pricing.cached_input_per_mtok_usd),
+ json_f64(pricing.cache_read_input_per_token.unwrap_or(0.0) * 1_000_000.0),
);
attrs.insert(
"gen_ai.pricing.output_per_mtok_usd".to_string(),
- json_f64(pricing.output_per_mtok_usd),
+ json_f64(pricing.output_per_token.unwrap_or(0.0) * 1_000_000.0),
);
}
diff --git a/crates/openhuman-core/src/inference/tokenjuice/savings.rs b/crates/openhuman-core/src/inference/tokenjuice/savings.rs
index 8bacba83a4..72f9932993 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/savings.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/savings.rs
@@ -153,7 +153,7 @@ pub fn record(
/// not price: the saving is then counted in tokens only, not guessed in USD.
fn cost_saved_usd(model: &str, tokens_saved: u64) -> f64 {
crate::agent::cost::lookup_pricing(model).map_or(0.0, |pricing| {
- (tokens_saved as f64) / 1_000_000.0 * pricing.input_per_mtok_usd
+ (tokens_saved as f64) * pricing.input_per_token.unwrap_or(0.0)
})
}