Skip to content

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

refactor: rename UsageInfo to BilledUsage across the codebase

Steven Enamakel005a53a7f72a
diff --git a/crates/openhuman-core/src/agent/context/manager.rs b/crates/openhuman-core/src/agent/context/manager.rs
index 92962ebfcd..1fe38b9c39 100644
--- a/crates/openhuman-core/src/agent/context/manager.rs
+++ b/crates/openhuman-core/src/agent/context/manager.rs
@@ -30,7 +30,7 @@ use super::session_memory::SessionMemoryConfig;
use super::stats::{ContextStatsState, SessionMemoryHandle};
use crate::agent::prompts::{PromptContext, SystemPromptBuilder};
use crate::config::ContextConfig;
-use crate::inference::provider::UsageInfo;
+use crate::inference::provider::BilledUsage;
use anyhow::Result;
/// Read-only snapshot of per-session context state. Returned by
@@ -159,9 +159,9 @@ impl ContextManager {
// ─── Budget tracking ──────────────────────────────────────────
- /// Feed the latest provider [`UsageInfo`] into utilisation stats and the
+ /// Feed the latest provider [`BilledUsage`] into utilisation stats and the
/// session-memory state.
- pub fn record_usage(&mut self, usage: &UsageInfo) {
+ pub fn record_usage(&mut self, usage: &BilledUsage) {
self.stats_state.record_usage(usage);
}
diff --git a/crates/openhuman-core/src/agent/context/manager_tests.rs b/crates/openhuman-core/src/agent/context/manager_tests.rs
index e9c4ef1ca0..cb724eff30 100644
--- a/crates/openhuman-core/src/agent/context/manager_tests.rs
+++ b/crates/openhuman-core/src/agent/context/manager_tests.rs
@@ -8,7 +8,7 @@
//! bookkeeping. These tests cover that surviving surface.
use super::*;
-use crate::inference::provider::UsageInfo;
+use crate::inference::provider::BilledUsage;
fn manager_with_config(config: &ContextConfig) -> ContextManager {
ContextManager::new(config, SystemPromptBuilder::with_defaults())
@@ -21,7 +21,7 @@ fn default_manager() -> ContextManager {
#[test]
fn stats_reports_snapshot() {
let mut manager = default_manager();
- manager.record_usage(&UsageInfo {
+ manager.record_usage(&BilledUsage {
input_tokens: 10_000,
output_tokens: 2_000,
context_window: 100_000,
@@ -82,7 +82,7 @@ fn autocompact_enabled_requires_both_master_and_autocompact_flags() {
#[test]
fn session_memory_lifecycle_changes_should_extract_state() {
let mut manager = default_manager();
- manager.record_usage(&UsageInfo {
+ manager.record_usage(&BilledUsage {
input_tokens: 20_000,
output_tokens: 0,
context_window: 100_000,
diff --git a/crates/openhuman-core/src/agent/context/stats.rs b/crates/openhuman-core/src/agent/context/stats.rs
index b9350a889a..a3afcfe0f9 100644
--- a/crates/openhuman-core/src/agent/context/stats.rs
+++ b/crates/openhuman-core/src/agent/context/stats.rs
@@ -7,7 +7,7 @@
use std::sync::{Arc, Mutex};
-use crate::inference::provider::UsageInfo;
+use crate::inference::provider::BilledUsage;
use super::session_memory::{SessionMemoryConfig, SessionMemoryState};
@@ -36,7 +36,7 @@ impl ContextStatsState {
}
}
- pub(crate) fn record_usage(&mut self, usage: &UsageInfo) {
+ pub(crate) fn record_usage(&mut self, usage: &BilledUsage) {
self.last_input_tokens = usage.input_tokens;
self.last_output_tokens = usage.output_tokens;
if usage.context_window > 0 {
diff --git a/crates/openhuman-core/src/agent/cost.rs b/crates/openhuman-core/src/agent/cost.rs
index 4b75822b97..135967a77a 100644
--- a/crates/openhuman-core/src/agent/cost.rs
+++ b/crates/openhuman-core/src/agent/cost.rs
@@ -1,6 +1,6 @@
//! Per-turn cost accounting for an agent's tool-call loop.
//!
-//! Each provider response carries an optional [`UsageInfo`] block with
+//! Each provider response carries an optional [`BilledUsage`] block with
//! `input_tokens`, `output_tokens`, `cached_input_tokens`, and an
//! authoritative `charged_amount_usd` populated by the OpenHuman
//! backend. [`TurnCost`] sums those across every provider call inside a
@@ -22,7 +22,7 @@
//! older cost records estimate sanely. Every other model — catalog ids the
//! user pins, BYOK vendor models — is priced from the vendor catalog.
-use crate::inference::provider::UsageInfo;
+use crate::inference::provider::BilledUsage;
/// Per-million-token rates for a single model tier.
///
@@ -101,7 +101,7 @@ pub(crate) fn lookup_pricing(model: &str) -> ModelPricing {
/// Estimate the USD cost of a single provider call from its token
/// usage. Used as a fallback when `charged_amount_usd` is missing.
-pub fn estimate_call_cost_usd(model: &str, usage: &UsageInfo) -> f64 {
+pub fn estimate_call_cost_usd(model: &str, usage: &BilledUsage) -> f64 {
let pricing = lookup_pricing(model);
let cached = usage.cached_input_tokens;
let standard_input = usage.input_tokens.saturating_sub(cached);
@@ -115,7 +115,7 @@ pub fn estimate_call_cost_usd(model: &str, usage: &UsageInfo) -> f64 {
///
/// Backend-reported `charged_amount_usd` wins whenever it's > 0;
/// otherwise we fall back to [`estimate_call_cost_usd`].
-pub fn call_cost_usd(model: &str, usage: &UsageInfo) -> f64 {
+pub fn call_cost_usd(model: &str, usage: &BilledUsage) -> f64 {
if usage.charged_amount_usd > 0.0 {
usage.charged_amount_usd
} else {
@@ -146,7 +146,7 @@ impl TurnCost {
}
/// Fold a single provider call's usage into the running totals.
- pub fn add_call(&mut self, model: &str, usage: &UsageInfo) {
+ pub fn add_call(&mut self, model: &str, usage: &BilledUsage) {
self.input_tokens = self.input_tokens.saturating_add(usage.input_tokens);
self.output_tokens = self.output_tokens.saturating_add(usage.output_tokens);
self.cached_input_tokens = self
diff --git a/crates/openhuman-core/src/agent/cost_tests.rs b/crates/openhuman-core/src/agent/cost_tests.rs
index c81c046491..5ccc059ec2 100644
--- a/crates/openhuman-core/src/agent/cost_tests.rs
+++ b/crates/openhuman-core/src/agent/cost_tests.rs
@@ -1,7 +1,7 @@
use super::*;
-fn usage(input: u64, output: u64, cached: u64, charged: f64) -> UsageInfo {
- UsageInfo {
+fn usage(input: u64, output: u64, cached: u64, charged: f64) -> BilledUsage {
+ BilledUsage {
input_tokens: input,
output_tokens: output,
cached_input_tokens: cached,
diff --git a/crates/openhuman-core/src/agent/goals/runtime_tests.rs b/crates/openhuman-core/src/agent/goals/runtime_tests.rs
index 0d079ab67f..b984857259 100644
--- a/crates/openhuman-core/src/agent/goals/runtime_tests.rs
+++ b/crates/openhuman-core/src/agent/goals/runtime_tests.rs
@@ -1,12 +1,12 @@
use super::*;
use crate::agent::cost::TurnCost;
-use crate::inference::provider::UsageInfo;
+use crate::inference::provider::BilledUsage;
fn cost_with_tokens(input: u64, output: u64) -> TurnCost {
let mut tc = TurnCost::new();
tc.add_call(
"agentic-v1",
- &UsageInfo {
+ &BilledUsage {
input_tokens: input,
output_tokens: output,
..Default::default()
diff --git a/crates/openhuman-core/src/agent/progress_tracing/journal_projection.rs b/crates/openhuman-core/src/agent/progress_tracing/journal_projection.rs
index a87cc708eb..5139844fe7 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/journal_projection.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/journal_projection.rs
@@ -492,7 +492,7 @@ fn observation_to_progress(obs: &AgentObservation, state: &mut ReplayState) -> V
// The token counts are exact; `cost_usd` is an estimate.
state.cost_usd += crate::agent::cost::estimate_call_cost_usd(
&state.model,
- &crate::inference::provider::UsageInfo {
+ &crate::inference::provider::BilledUsage {
input_tokens: usage.input_tokens,
output_tokens: usage.output_tokens,
context_window: 0,
diff --git a/crates/openhuman-core/src/agent/session_host/driver.rs b/crates/openhuman-core/src/agent/session_host/driver.rs
index 8e9d0ee915..27f52a66ec 100644
--- a/crates/openhuman-core/src/agent/session_host/driver.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver.rs
@@ -517,7 +517,7 @@ fn driver_error_with_snapshot(
.unwrap_or(fallback_model);
crate::agent::cost::estimate_call_cost_usd(
pricing_model,
- &crate::inference::provider::UsageInfo {
+ &crate::inference::provider::BilledUsage {
input_tokens: guard.input_tokens,
output_tokens: guard.output_tokens,
context_window: 0,
diff --git a/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs b/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs
index 95821c5a8b..0a38ec7f23 100644
--- a/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs
@@ -21,7 +21,7 @@ use crate::agent::{
},
tinyagents::{TinyagentsTurnOutcome, TurnModelSource},
};
-use crate::inference::provider::{ChatResponse, UsageInfo, AGENT_TURN_MAX_OUTPUT_TOKENS};
+use crate::inference::provider::{ChatResponse, BilledUsage, AGENT_TURN_MAX_OUTPUT_TOKENS};
/// Accounting from model calls performed after the harness loop has ended.
#[derive(Default)]
@@ -34,7 +34,7 @@ pub(super) struct RepairUsage {
}
impl RepairUsage {
- fn record(&mut self, usage: Option<UsageInfo>) {
+ fn record(&mut self, usage: Option<BilledUsage>) {
self.model_calls += 1;
if let Some(usage) = usage {
self.input_tokens += usage.input_tokens;
@@ -249,9 +249,9 @@ async fn close_with_one_repair<A, AF, V, VF>(
) -> (String, RepairUsage)
where
A: Fn(String) -> AF,
- AF: std::future::Future<Output = (String, Option<UsageInfo>)>,
+ AF: std::future::Future<Output = (String, Option<BilledUsage>)>,
V: Fn(String) -> VF,
- VF: std::future::Future<Output = (Option<CloseViolation>, Option<UsageInfo>)>,
+ VF: std::future::Future<Output = (Option<CloseViolation>, Option<BilledUsage>)>,
{
let mut usage = RepairUsage::default();
let mut prompt = instruction.clone();
@@ -289,7 +289,7 @@ async fn completion(
temperature: f64,
thread_id: Option<&str>,
messages: Vec<ChatMessage>,
-) -> (String, Option<UsageInfo>) {
+) -> (String, Option<BilledUsage>) {
let Ok(model_client) = source.build_summarizer(model, temperature, thread_id) else {
return (String::new(), None);
};
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs b/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs
index 9ee6166ed5..63ced1b11a 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs
@@ -5,7 +5,7 @@
//! instead of erroring. Falls back to a deterministic digest summary if the
//! summarization call fails or returns no prose.
-use crate::inference::provider::UsageInfo;
+use crate::inference::provider::BilledUsage;
use std::sync::Arc;
use tinyinference_llm::message::Message;
use tinyinference_llm::model::{ChatModel, ModelRequest};
@@ -14,7 +14,7 @@ use tinyinference_llm::model::{ChatModel, ModelRequest};
/// summary call so the caller can fold it into sub-agent token/cost accounting.
pub(super) struct SubagentCheckpointOutcome {
pub(super) text: String,
- pub(super) usage: Option<UsageInfo>,
+ pub(super) usage: Option<BilledUsage>,
}
/// Sub-agent cap-hit summary: when the iteration cap is hit, summarize the
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs b/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs
index 71c77055d8..75ab409c87 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs
@@ -411,7 +411,7 @@ pub(in super::super) async fn run_subagent_via_graph(
usage.charged_amount_usd += call_cost;
crate::platform::cost::record_provider_usage(
model,
- &crate::inference::provider::UsageInfo {
+ &crate::inference::provider::BilledUsage {
input_tokens: u.input_tokens,
output_tokens: u.output_tokens,
context_window: u.context_window,
diff --git a/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs b/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs
index c93cbdc70e..7a67ddf22a 100644
--- a/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs
@@ -56,7 +56,7 @@ pub(super) struct AssembledTurnHarness {
///
/// Real success + a user-facing failure + timing onto `ToolCallCompleted`.
pub(super) failure_map: ToolFailureMap,
- /// Shared FIFO carry of per-call provider `UsageInfo` (charged USD + context
+ /// Shared FIFO carry of per-call provider `BilledUsage` (charged USD + context
/// window): the model adapter pushes, the event bridge pops when recording
/// usage — restores charged-USD precedence on the tinyagents path (#4467).
pub(super) provider_usage_carry: ProviderUsageCarry,
@@ -202,7 +202,7 @@ pub(super) fn assemble_turn_harness(
// tool-call start (the crate `ToolDelta` carries none), the bridge reads it
// to label the argument fragments now streamed via `MessageDelta.tool_call`.
let tool_names: ToolNameMap = Arc::default();
- // Shared FIFO carry of per-call provider `UsageInfo`: `UsageCarryMiddleware`
+ // Shared FIFO carry of per-call provider `BilledUsage`: `UsageCarryMiddleware`
// pushes each response's usage (charged USD + context window +
// cache-creation/reasoning tokens, read off the response via G1), the event
// bridge pops it when recording that call's usage (#4467, item 1). The carry
@@ -250,7 +250,7 @@ pub(super) fn assemble_turn_harness(
}
// Cost usage capture (issue #4249, Phase 5): feed the event bridge's usage
- // carry from a wrap-model middleware that reads the full `UsageInfo` off each
+ // carry from a wrap-model middleware that reads the full `BilledUsage` off each
// response, instead of every `native model adapter` pushing it. Installed
// unconditionally — usage flows on every turn — and shares the same carry the
// bridge drains on `UsageRecorded`.
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs
index 7eea0665d4..84536d701a 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs
@@ -288,7 +288,7 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>
let host_usage = crate::agent::tinyagents::model::usage_info_from_response(
response,
)
- .unwrap_or(crate::inference::provider::UsageInfo {
+ .unwrap_or(crate::inference::provider::BilledUsage {
input_tokens: usage.input_tokens,
output_tokens: usage.output_tokens,
context_window: 0,
diff --git a/crates/openhuman-core/src/agent/tinyagents/model.rs b/crates/openhuman-core/src/agent/tinyagents/model.rs
index fed22c31fe..849c7507e5 100644
--- a/crates/openhuman-core/src/agent/tinyagents/model.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/model.rs
@@ -10,7 +10,7 @@ use tinyinference_llm::model::{
use tinyinference_llm::tool::ToolCall as TaToolCall;
use tinyinference_llm::usage::Usage;
-use crate::inference::provider::{ChatResponse, UsageInfo};
+use crate::inference::provider::{ChatResponse, BilledUsage};
pub(super) type TurnChatModel = Arc<dyn ChatModel<()>>;
pub(super) type TierRoutes = Vec<(String, TurnChatModel)>;
@@ -210,14 +210,14 @@ pub(crate) fn prompt_guided_text_response(text: String, request: &ModelRequest)
/// (gap G1). Consumed by [`usage_info_from_response`].
const OPENHUMAN_USAGE_META_KEY: &str = "openhuman_usage_meta";
-/// The two host [`UsageInfo`] fields with no crate [`Usage`] home, ferried
+/// The two host [`BilledUsage`] fields with no crate [`Usage`] home, ferried
/// through [`ModelResponse::raw`] so a standalone `invoke` stays usage-faithful.
#[derive(Debug, Clone, Copy, Default, serde::Serialize, serde::Deserialize)]
struct OpenhumanUsageMeta {
- /// Provider-charged amount in USD (`UsageInfo::charged_amount_usd`).
+ /// Provider-charged amount in USD (`BilledUsage::charged_amount_usd`).
#[serde(default)]
charged_amount_usd: f64,
- /// Model context window in tokens (`UsageInfo::context_window`).
+ /// Model context window in tokens (`BilledUsage::context_window`).
#[serde(default)]
context_window: u64,
}
@@ -225,7 +225,7 @@ struct OpenhumanUsageMeta {
/// Build the `ModelResponse.raw` value carrying charged-USD + context-window
/// metadata, or `None` when the provider reported neither (so responses from
/// providers that don't surface billing stay `raw: None`).
-fn openhuman_usage_meta_raw(usage: Option<&UsageInfo>) -> Option<serde_json::Value> {
+fn openhuman_usage_meta_raw(usage: Option<&BilledUsage>) -> Option<serde_json::Value> {
let u = usage?;
if u.charged_amount_usd <= 0.0 && u.context_window == 0 {
return None;
@@ -278,7 +278,7 @@ pub(crate) fn merge_openhuman_usage_meta(
}
}
-/// Reconstruct a host [`UsageInfo`] from a crate [`ModelResponse`], recovering
+/// Reconstruct a host [`BilledUsage`] from a crate [`ModelResponse`], recovering
/// the provider-charged USD + context window the adapter stashed in
/// [`ModelResponse::raw`] (gap G1). Returns `None` when the response carried no
/// usage at all.
@@ -287,7 +287,7 @@ pub(crate) fn merge_openhuman_usage_meta(
/// the legacy chat response onto `Arc<dyn ChatModel>`
/// (`invoke` → `ModelResponse`): the full host usage record — real token
/// counts *and* backend-charged USD — survives the crossing.
-pub(crate) fn usage_info_from_response(response: &ModelResponse) -> Option<UsageInfo> {
+pub(crate) fn usage_info_from_response(response: &ModelResponse) -> Option<BilledUsage> {
let usage = response.usage.as_ref()?;
let mut meta = response
.raw
@@ -303,7 +303,7 @@ pub(crate) fn usage_info_from_response(response: &ModelResponse) -> Option<Usage
.and_then(serde_json::Value::as_f64)
.unwrap_or_default();
}
- Some(UsageInfo {
+ Some(BilledUsage {
input_tokens: usage.input_tokens,
output_tokens: usage.output_tokens,
context_window: meta.context_window,
diff --git a/crates/openhuman-core/src/agent/tinyagents/model_g1_usage_tests_tests.rs b/crates/openhuman-core/src/agent/tinyagents/model_g1_usage_tests_tests.rs
index 892658998b..dfcac0b931 100644
--- a/crates/openhuman-core/src/agent/tinyagents/model_g1_usage_tests_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/model_g1_usage_tests_tests.rs
@@ -13,7 +13,7 @@ fn usage_round_trips_charged_usd_and_all_token_breakdowns() {
let chat = ChatResponse {
text: Some("hi".to_string()),
tool_calls: Vec::new(),
- usage: Some(UsageInfo {
+ usage: Some(BilledUsage {
input_tokens: 100,
output_tokens: 20,
context_window: 128_000,
@@ -55,7 +55,7 @@ fn no_billing_metadata_leaves_raw_clean() {
let chat = ChatResponse {
text: Some("hi".to_string()),
tool_calls: Vec::new(),
- usage: Some(UsageInfo {
+ usage: Some(BilledUsage {
input_tokens: 5,
output_tokens: 3,
..Default::default()
diff --git a/crates/openhuman-core/src/agent/tinyagents/observability/cap_pauser.rs b/crates/openhuman-core/src/agent/tinyagents/observability/cap_pauser.rs
index 2b32ef6b37..4e6086cc6a 100644
--- a/crates/openhuman-core/src/agent/tinyagents/observability/cap_pauser.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/observability/cap_pauser.rs
@@ -72,20 +72,20 @@ pub(crate) type ToolFailureMap = Arc<
>,
>;
-/// Shared FIFO carry of the per-call provider [`UsageInfo`](crate::inference::provider::UsageInfo)
+/// Shared FIFO carry of the per-call provider [`BilledUsage`](crate::inference::provider::BilledUsage)
/// the model adapter observed, drained by the bridge when it records that
/// call's usage. The crate `Usage` the harness surfaces on
/// `AgentEvent::UsageRecorded` carries only token counts, so the
/// backend-charged USD, the model's context window, and the
/// cache-creation/reasoning token breakdown have no crate home — the model
-/// adapter pushes the full provider `UsageInfo` here (one push per provider
+/// adapter pushes the full provider `BilledUsage` here (one push per provider
/// response) and the bridge pops it (one pop per recorded model call, after the
/// duplicate-usage dedupe guard) to restore charged-USD precedence and the full
/// accounting (#4467, item 1). A pop that finds nothing (a fallback-route call
/// that did not push, or an out-of-band usage event) degrades gracefully to a
/// catalogue estimate.
pub(crate) type ProviderUsageCarry =
- Arc<Mutex<std::collections::VecDeque<crate::inference::provider::UsageInfo>>>;
+ Arc<Mutex<std::collections::VecDeque<crate::inference::provider::BilledUsage>>>;
/// An [`EventListener`] that pauses the run once `cap` model calls have
/// completed, so the loop stops gracefully at the iteration budget (returning
diff --git a/crates/openhuman-core/src/agent/tinyagents/observability/event_bridge.rs b/crates/openhuman-core/src/agent/tinyagents/observability/event_bridge.rs
index cabe8a25b4..65057adf98 100644
--- a/crates/openhuman-core/src/agent/tinyagents/observability/event_bridge.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/observability/event_bridge.rs
@@ -10,7 +10,7 @@ use tokio::sync::mpsc::Sender;
use tinyinference_llm::usage::Usage;
use crate::agent::progress::AgentProgress;
-use crate::inference::provider::UsageInfo;
+use crate::inference::provider::BilledUsage;
use tinytools::humanize_tool_name;
use super::cap_pauser::{
@@ -68,7 +68,7 @@ pub(crate) struct OpenhumanEventBridge {
/// side-channel written by `ToolOutcomeCaptureMiddleware`; read when
/// projecting `ToolCallCompleted`.
pub(super) failure_map: ToolFailureMap,
- /// Shared FIFO carry of the per-call provider `UsageInfo` the model adapter
+ /// Shared FIFO carry of the per-call provider `BilledUsage` the model adapter
/// observed; drained in `record_usage` to restore backend-charged USD +
/// context-window + cache-creation/reasoning tokens the crate `Usage` drops.
pub(super) usage_carry: ProviderUsageCarry,
@@ -437,7 +437,7 @@ impl OpenhumanEventBridge {
// Feed the authoritative global cost tracker (same call the legacy
// observer made), so the wallet/cost surfaces stay accurate.
- let usage_info = UsageInfo {
+ let usage_info = BilledUsage {
input_tokens: usage.input_tokens,
output_tokens: usage.output_tokens,
context_window,
@@ -484,7 +484,7 @@ impl OpenhumanEventBridge {
pub(super) fn estimate_call_cost(model: &str, usage: &Usage) -> f64 {
crate::agent::cost::estimate_call_cost_usd(
model,
- &UsageInfo {
+ &BilledUsage {
input_tokens: usage.input_tokens,
output_tokens: usage.output_tokens,
context_window: 0,
diff --git a/crates/openhuman-core/src/agent/tinyagents/routes.rs b/crates/openhuman-core/src/agent/tinyagents/routes.rs
index 63df73f180..58de070a28 100644
--- a/crates/openhuman-core/src/agent/tinyagents/routes.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/routes.rs
@@ -227,7 +227,7 @@ impl ModelMiddleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>
}
/// Around-model middleware that feeds the cost event bridge (issue #4249,
-/// Phase 5): after the real model call, it reads the full host [`UsageInfo`] off
+/// Phase 5): after the real model call, it reads the full host [`BilledUsage`] off
/// the returned [`ModelResponse`] — token breakdowns from the crate `Usage`,
/// backend-charged USD + context window from the G1 `raw` passthrough
/// ([`usage_info_from_response`](super::model::usage_info_from_response)) — and
diff --git a/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rs b/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rs
index 4460824ffb..51e126a246 100644
--- a/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rs
@@ -30,7 +30,7 @@ use tinyinference_llm::model::ModelResponse;
use crate::agent::cost::TurnCost;
use crate::agent::stop_hooks::{StopDecision, StopHook, TurnState};
-use crate::inference::provider::UsageInfo;
+use crate::inference::provider::BilledUsage;
/// Fires openhuman [`StopHook`]s after each model call and pauses the run when
/// any hook votes to stop.
@@ -101,7 +101,7 @@ where
if let Some(usage) = &response.usage {
cost.add_call(
&self.model,
- &UsageInfo {
+ &BilledUsage {
input_tokens: usage.input_tokens,
output_tokens: usage.output_tokens,
context_window: 0,
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_outcome.rs b/crates/openhuman-core/src/agent/tinyagents/turn_outcome.rs
index a2a2a85685..184a76aa16 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_outcome.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_outcome.rs
@@ -134,7 +134,7 @@ pub(crate) fn record_unobserved_turn_usage(
);
crate::platform::cost::record_provider_usage(
model,
- &crate::inference::provider::UsageInfo {
+ &crate::inference::provider::BilledUsage {
input_tokens,
output_tokens,
context_window: 0,
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/prompt.rs b/crates/openhuman-core/src/flows/tinyflows/caps/prompt.rs
index 112509439f..2c0e8112f9 100644
--- a/crates/openhuman-core/src/flows/tinyflows/caps/prompt.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/caps/prompt.rs
@@ -19,7 +19,7 @@ use tinyflows::error::{EngineError, Result};
use super::*;
use crate::agent::messages::ChatMessage;
use crate::config::Config;
-use crate::inference::provider::{is_raw_passthrough_model, UsageInfo};
+use crate::inference::provider::{is_raw_passthrough_model, BilledUsage};
use tinyflows::nodes::integration::agent_prompt;
/// [`agent_prompt::build_completion_messages`] mapped onto the host's
@@ -36,10 +36,10 @@ pub(crate) fn build_completion_messages(request: &Value) -> Vec<ChatMessage> {
.collect()
}
-/// Maps a `UsageInfo` (not `Serialize`) into a JSON value field-by-field, so
+/// Maps a `BilledUsage` (not `Serialize`) into a JSON value field-by-field, so
/// [`OpenHumanLlm::complete`] can surface it in its response `Value` without
/// requiring an upstream `Serialize` impl change.
-pub(crate) fn usage_to_json(usage: &Option<UsageInfo>) -> Value {
+pub(crate) fn usage_to_json(usage: &Option<BilledUsage>) -> Value {
match usage {
None => Value::Null,
Some(u) => json!({
diff --git a/crates/openhuman-core/src/inference/provider/openhuman_backend_model_tests.rs b/crates/openhuman-core/src/inference/provider/openhuman_backend_model_tests.rs
index 9ebf5ceadb..6a77687799 100644
--- a/crates/openhuman-core/src/inference/provider/openhuman_backend_model_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/openhuman_backend_model_tests.rs
@@ -50,7 +50,7 @@ fn resolve_model_normalizes_blank_and_trims_non_empty_values() {
}
/// The managed `openhuman.{billing,usage}` envelope on `raw` must re-project
-/// into the host `UsageInfo` the cost bridge reads — charged USD, cached
+/// into the host `BilledUsage` the cost bridge reads — charged USD, cached
/// tokens, and context window — exactly as the legacy legacy model-adapter path did.
#[test]
fn project_managed_usage_recovers_charged_and_cached() {
diff --git a/crates/openhuman-core/src/platform/cost/global.rs b/crates/openhuman-core/src/platform/cost/global.rs
index 54978712fd..24804b4475 100644
--- a/crates/openhuman-core/src/platform/cost/global.rs
+++ b/crates/openhuman-core/src/platform/cost/global.rs
@@ -20,7 +20,7 @@ use std::sync::Arc;
use parking_lot::RwLock;
use crate::config::CostConfig;
-use crate::inference::provider::types::UsageInfo;
+use crate::inference::provider::types::BilledUsage;
use super::tracker::CostTracker;
use super::types::{CostSource, TokenUsage};
@@ -131,7 +131,7 @@ pub fn try_global() -> Option<Arc<CostTracker>> {
}
/// Convenience hook used by the agent turn loop: translates a provider
-/// [`UsageInfo`] into a [`TokenUsage`] record and persists it via the
+/// [`BilledUsage`] into a [`TokenUsage`] record and persists it via the
/// global tracker. Silently skipped when the tracker is uninitialised.
/// Errors are logged but never propagated — cost tracking must never
/// break a turn.
@@ -143,7 +143,7 @@ pub fn try_global() -> Option<Arc<CostTracker>> {
/// `model` is the model identifier the request was routed to (e.g.
/// `"anthropic/claude-sonnet-4-20250514"`) and is used as the bucket key
/// in per-model aggregates.
-pub fn record_provider_usage(model: &str, usage: &UsageInfo) {
+pub fn record_provider_usage(model: &str, usage: &BilledUsage) {
let Some(token_usage) = build_token_usage(model, usage) else {
return;
};
@@ -155,15 +155,15 @@ pub fn record_provider_usage(model: &str, usage: &UsageInfo) {
}
}
-/// Translate a provider [`UsageInfo`] into a [`TokenUsage`] record.
+/// Translate a provider [`BilledUsage`] into a [`TokenUsage`] record.
///
/// Returns `None` for an all-zero payload so the caller can skip the
-/// write — providers that don't echo usage produce `UsageInfo::default()`
+/// write — providers that don't echo usage produce `BilledUsage::default()`
/// values, and persisting those would inflate the request count with
/// non-events. Non-finite or negative cost is clamped to `0.0`. Extracted
/// from [`record_provider_usage`] so the translation can be unit-tested
/// independently of the process-global tracker singleton.
-pub(super) fn build_token_usage(model: &str, usage: &UsageInfo) -> Option<TokenUsage> {
+pub(super) fn build_token_usage(model: &str, usage: &BilledUsage) -> Option<TokenUsage> {
if usage.input_tokens == 0 && usage.output_tokens == 0 && usage.charged_amount_usd == 0.0 {
return None;
}
diff --git a/crates/openhuman-core/src/platform/cost/global_tests.rs b/crates/openhuman-core/src/platform/cost/global_tests.rs
index a8c6b29932..5e0b74de52 100644
--- a/crates/openhuman-core/src/platform/cost/global_tests.rs
+++ b/crates/openhuman-core/src/platform/cost/global_tests.rs
@@ -3,8 +3,8 @@ use crate::platform::cost::tracker_test_lock;
use crate::platform::cost::types::CostRecord;
use tempfile::TempDir;
-fn make_usage(input: u64, output: u64, charged: f64) -> UsageInfo {
- UsageInfo {
+fn make_usage(input: u64, output: u64, charged: f64) -> BilledUsage {
+ BilledUsage {
input_tokens: input,
output_tokens: output,
context_window: 0,
diff --git a/crates/openhuman-core/src/threads/ops/usage.rs b/crates/openhuman-core/src/threads/ops/usage.rs
index f4da1026af..90b7bedc5f 100644
--- a/crates/openhuman-core/src/threads/ops/usage.rs
+++ b/crates/openhuman-core/src/threads/ops/usage.rs
@@ -68,7 +68,7 @@ pub async fn token_usage(
|model: Option<&str>, input: u64, output: u64, cached: u64, fallback: f64| match model {
Some(m) => crate::agent::cost::estimate_call_cost_usd(
m,
- &crate::inference::provider::UsageInfo {
+ &crate::inference::provider::BilledUsage {
input_tokens: input,
output_tokens: output,
cached_input_tokens: cached,