The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(provider): replace UsageInfo with BilledUsage
Steven Enamakel9a707bfc71d7
diff --git a/crates/openhuman-core/src/inference/provider/mod.rs b/crates/openhuman-core/src/inference/provider/mod.rsindex 16a623a918..fe51ecd1da 100644--- a/crates/openhuman-core/src/inference/provider/mod.rs+++ b/crates/openhuman-core/src/inference/provider/mod.rs@@ -17,7 +17,7 @@ pub mod types;#[allow(unused_imports)]pub use types::{- ChatRequest, ChatResponse, ProviderDelta, UsageInfo, AGENT_TURN_MAX_OUTPUT_TOKENS,+ ChatRequest, ChatResponse, ProviderDelta, BilledUsage, AGENT_TURN_MAX_OUTPUT_TOKENS,};pub use error_code::{diff --git a/crates/openhuman-core/src/inference/provider/types.rs b/crates/openhuman-core/src/inference/provider/types.rsindex 5a5c2933c0..1770d887c8 100644--- a/crates/openhuman-core/src/inference/provider/types.rs+++ b/crates/openhuman-core/src/inference/provider/types.rs@@ -1,11 +1,72 @@use crate::agent::messages::ChatMessage;-/// Token usage returned by a provider. Defined in the contract crate because-/// the extracted memory subsystem threads it out of summarisation runs; every-/// existing `inference::provider::UsageInfo` path keeps naming this one type.-pub use tinymemory_api::host::UsageInfo;+use tinyinference_llm::usage::Usage;use tinytools::ToolSpec;use tinytools_agent::dialect::NativeToolCall;+/// Token usage returned by a provider: the vendor [`Usage`] token counts plus+/// the host-owned billing the vendor type deliberately does not carry.+///+/// `usage` is the single token-count representation threaded everywhere+/// (cache reads/writes, reasoning tokens and the context window all have+/// homes on it). Only the provider-charged amount stays host data: it is kept+/// as an exact `f64` USD value (the vendor `ChargedAmount` is integer micro+/// units and would round the persisted cost rows). `Deref` exposes the+/// vendor fields (`input_tokens`, `output_tokens`, `cache_creation_tokens`,+/// `reasoning_tokens`, ...) directly.+#[derive(Debug, Clone, Copy, Default, PartialEq)]+pub struct BilledUsage {+ /// Vendor token counts for the call.+ pub usage: Usage,+ /// Amount billed for this request in USD (from+ /// `openhuman.billing.charged_amount_usd`). Zero when unavailable.+ pub charged_amount_usd: f64,+}++impl BilledUsage {+ /// Plain token counts with no cache breakdown, context window or charge.+ pub fn from_counts(input_tokens: u64, output_tokens: u64) -> Self {+ Self {+ usage: Usage::new(input_tokens, output_tokens),+ charged_amount_usd: 0.0,+ }+ }++ /// Input tokens served from the provider prompt/KV cache.+ pub fn cached_input_tokens(&self) -> u64 {+ self.usage.cache_read_tokens+ }++ /// Model context window in tokens; `0` when unknown.+ pub fn context_window(&self) -> u64 {+ self.usage.context_window_tokens.unwrap_or(0)+ }++ /// Sets the cache-read token count.+ pub fn with_cached_input_tokens(mut self, tokens: u64) -> Self {+ self.usage.cache_read_tokens = tokens;+ self+ }++ /// Sets the context window (`0` means unknown).+ pub fn with_context_window(mut self, tokens: u64) -> Self {+ self.usage.context_window_tokens = (tokens > 0).then_some(tokens);+ self+ }++ /// Sets the provider-charged USD amount.+ pub fn with_charged_usd(mut self, usd: f64) -> Self {+ self.charged_amount_usd = usd;+ self+ }+}++impl std::ops::Deref for BilledUsage {+ type Target = Usage;+ fn deref(&self) -> &Usage {+ &self.usage+ }+}+/// An LLM response that may contain text, tool calls, or both.#[derive(Debug, Clone, Default)]pub struct ChatResponse {@@ -14,7 +75,7 @@ pub struct ChatResponse {/// Tool calls requested by the LLM.pub tool_calls: Vec<NativeToolCall>,/// Token usage info from the provider (if available).- pub usage: Option<UsageInfo>,+ pub usage: Option<BilledUsage>,/// Raw reasoning/thinking content returned by thinking models (e.g./// DeepSeek-R1, Qwen3) in the `reasoning_content` field. This must be/// passed back verbatim on the next turn — the API returns HTTP 400