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
refactor(core): migrate usage and cost types to tinyinference_llm
Steven Enamakel08a24cce6f05
diff --git a/crates/openhuman-core/src/agent/agent_tests.rs b/crates/openhuman-core/src/agent/agent_tests.rsindex c8e495acd4..e1ac9f2b5d 100644--- a/crates/openhuman-core/src/agent/agent_tests.rs+++ b/crates/openhuman-core/src/agent/agent_tests.rs@@ -26,7 +26,7 @@use crate::agent::session_host::OpenHumanSessionHost;use crate::config::AgentConfig;-use crate::inference::provider::ChatResponse;+use tinyinference_llm::model::ChatResponse;use anyhow::Result;use async_trait::async_trait;use std::sync::{Arc, Mutex};diff --git a/crates/openhuman-core/src/agent/cost.rs b/crates/openhuman-core/src/agent/cost.rsindex b548a38f36..108c828da9 100644--- a/crates/openhuman-core/src/agent/cost.rs+++ b/crates/openhuman-core/src/agent/cost.rs@@ -16,7 +16,7 @@//! to exist ($3 / $0.30 / $15 per MTok) and priced a glm-5.3-flash thread at//! $4.25 when the provider billed about $0.30.-use crate::inference::provider::BilledUsage;+use tinyinference_llm::usage::BilledUsage;use tinyagents_harness::cost::{CallCost, CallUsage};/// Whether a model names an explicitly free OpenRouter variant.diff --git a/crates/openhuman-core/src/agent/cost_tests.rs b/crates/openhuman-core/src/agent/cost_tests.rsindex 3c8078b96d..10b022da54 100644--- a/crates/openhuman-core/src/agent/cost_tests.rs+++ b/crates/openhuman-core/src/agent/cost_tests.rs@@ -11,7 +11,7 @@ fn counts(input: u64, output: u64, cached: u64) -> BilledUsage {fn record(turn: &mut tinyagents_harness::cost::TurnCost, model: &str, usage: &BilledUsage) {use tinyagents_hooks::stop::StopHookMetrics as _;let response = tinyinference_llm::model::response_to_model_response(- &crate::inference::provider::ChatResponse {+ &tinyinference_llm::model::ChatResponse {text: Some("ok".into()),usage: Some(*usage),..Default::default()diff --git a/crates/openhuman-core/src/agent/harness/graph.rs b/crates/openhuman-core/src/agent/harness/graph.rsindex ed014dc4a1..02dad590e4 100644--- a/crates/openhuman-core/src/agent/harness/graph.rs+++ b/crates/openhuman-core/src/agent/harness/graph.rs@@ -179,7 +179,7 @@ pub(crate) async fn run_channel_turn_via_graph(pause_at_cap: false,// Bound the model's per-call output (legacy parity — channel turns ran at// the standard per-turn budget).- max_output_tokens: Some(crate::inference::provider::AGENT_TURN_MAX_OUTPUT_TOKENS),+ max_output_tokens: Some(crate::agent::tinyagents::turn_policy::AGENT_TURN_MAX_OUTPUT_TOKENS),// Context middlewares: cache-align + default tool-result byte cap (the// channel path has no session context config to source from).context_mw:diff --git a/crates/openhuman-core/src/agent/session_host/driver.rs b/crates/openhuman-core/src/agent/session_host/driver.rsindex a3dd6383d7..258ef8e883 100644--- a/crates/openhuman-core/src/agent/session_host/driver.rs+++ b/crates/openhuman-core/src/agent/session_host/driver.rs@@ -212,7 +212,7 @@ impl SessionDriver<OpenHumanRunContext> for OpenHumanSessionDriver {message_run_queue: None,early_exit_tools: &["ask_user_clarification"],pause_at_cap: true,- max_output_tokens: Some(crate::inference::provider::AGENT_TURN_MAX_OUTPUT_TOKENS),+ max_output_tokens: Some(crate::agent::tinyagents::turn_policy::AGENT_TURN_MAX_OUTPUT_TOKENS),context_mw,tool_policy: Some(tool_policy),deterministic_cacheable: false,diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs b/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rsindex 0ed7441bb4..ee52de7ad5 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs@@ -1,6 +1,6 @@//! OpenHuman billing adapter for TinyAgents' cap-hit checkpoint summary.-use crate::inference::provider::BilledUsage;+use tinyinference_llm::usage::BilledUsage;use std::sync::{Arc, Mutex};use tinyagents_harness::summarization::CapToolResult;use tinyagents_orchestration::subagent::{summarize_at_cap, CapSummaryModel};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.rsindex b5aa371405..c6b8dee08a 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@@ -417,7 +417,7 @@ pub(in super::super) async fn run_subagent_via_graph(usage.cached_input_tokens += u.cached_input_tokens();let call_cost = crate::agent::cost::call_cost(model, &u);usage.cost.add(call_cost);- let billed = crate::inference::provider::BilledUsage::from_counts(+ let billed = tinyinference_llm::usage::BilledUsage::from_counts(u.input_tokens,u.output_tokens,)diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rsindex b4a79fd134..f1d47c5257 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs@@ -22,7 +22,7 @@ use crate::agent::subagent_host::types::{};use crate::agent::tinyagents::budget::MAX_SPAWN_DEPTH;use crate::agent_registry::host_definition::{AgentDefinition, AgentDefinitionRegistry};-use crate::inference::provider::AGENT_TURN_MAX_OUTPUT_TOKENS;+use crate::agent::tinyagents::turn_policy::AGENT_TURN_MAX_OUTPUT_TOKENS;use tinyagents_definition::{validate_tier_transition, AgentTier, IterationPolicy, PromptSource,SandboxMode as AgentSandboxMode,diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rsindex f709e30dd5..964c528059 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs@@ -275,7 +275,7 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>let host_usage =tinyinference_llm::usage::usage_info_from_response(response).unwrap_or(- crate::inference::provider::BilledUsage::from_counts(+ tinyinference_llm::usage::BilledUsage::from_counts(usage.input_tokens,usage.output_tokens,)diff --git a/crates/openhuman-core/src/agent/tinyagents/observability/bridge_types.rs b/crates/openhuman-core/src/agent/tinyagents/observability/bridge_types.rsindex e7dfcce865..4f29b412e4 100644--- a/crates/openhuman-core/src/agent/tinyagents/observability/bridge_types.rs+++ b/crates/openhuman-core/src/agent/tinyagents/observability/bridge_types.rs@@ -58,7 +58,7 @@ pub(crate) type ToolFailureMap = Arc<>,>;-/// Shared FIFO carry of the per-call provider [`BilledUsage`](crate::inference::provider::BilledUsage)+/// Shared FIFO carry of the per-call provider [`BilledUsage`](tinyinference_llm::usage::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@@ -71,4 +71,4 @@ pub(crate) type ToolFailureMap = Arc</// 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::BilledUsage>>>;+ Arc<Mutex<std::collections::VecDeque<tinyinference_llm::usage::BilledUsage>>>;diff --git a/crates/openhuman-core/src/agent/tinyagents/observability/event_bridge.rs b/crates/openhuman-core/src/agent/tinyagents/observability/event_bridge.rsindex b26d93f9c5..a44e9aef4b 100644--- a/crates/openhuman-core/src/agent/tinyagents/observability/event_bridge.rs+++ b/crates/openhuman-core/src/agent/tinyagents/observability/event_bridge.rs@@ -9,7 +9,7 @@ use tokio::sync::mpsc::Sender;use tinyinference_llm::usage::Usage;-use crate::inference::provider::BilledUsage;+use tinyinference_llm::usage::BilledUsage;use crate::progress::AgentProgress;use tinytools::humanize_tool_name;diff --git a/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs b/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rsindex e384feca9b..f81b02cc08 100644--- a/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs+++ b/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs@@ -101,7 +101,7 @@ impl HarnessPayloadSummarizer<OpenHumanRunContext> for SubagentPayloadSummarizerlet thread_id = parent_ctx.data.thread_id.clone();let max_output_tokens = definition.max_turn_output_tokens- .unwrap_or(crate::inference::provider::AGENT_TURN_MAX_OUTPUT_TOKENS);+ .unwrap_or(crate::agent::tinyagents::turn_policy::AGENT_TURN_MAX_OUTPUT_TOKENS);let child_context = unary_child_context(parent_ctx,&definition.id,diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_outcome.rs b/crates/openhuman-core/src/agent/tinyagents/turn_outcome.rsindex f861dbaca5..98ee963a47 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_outcome.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_outcome.rs@@ -207,7 +207,7 @@ pub(crate) fn record_unobserved_turn_usage(?estimated_usd,"[tinyagents] recording unobserved-turn usage into the global cost tracker");- let usage = crate::inference::provider::BilledUsage::from_counts(input_tokens, output_tokens)+ let usage = tinyinference_llm::usage::BilledUsage::from_counts(input_tokens, output_tokens).with_cached_input_tokens(cached_input_tokens);// No per-call charge reached this path; record the catalog estimate when// the model has one, else the record stays unpriced.diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs b/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rsindex bd60e759f9..4028db9364 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs@@ -112,7 +112,7 @@ pub(super) async fn finalize_turn_outcome(// model has a list price, else the turn's cost is unknown.let estimate = crate::agent::cost::estimate_call_cost_usd(model,- &crate::inference::provider::BilledUsage::from_counts(input, output)+ &tinyinference_llm::usage::BilledUsage::from_counts(input, output).with_cached_input_tokens(cached),);crate::agent::tinyagents::turn_outcome::record_unobserved_turn_usage(diff --git a/crates/openhuman-core/src/flows/caps_host/prompt.rs b/crates/openhuman-core/src/flows/caps_host/prompt.rsindex a5ec797dd7..4e6c9acf43 100644--- a/crates/openhuman-core/src/flows/caps_host/prompt.rs+++ b/crates/openhuman-core/src/flows/caps_host/prompt.rs@@ -18,7 +18,7 @@ pub(crate) fn build_completion_messages(messages: &[CompletionMessage]) -> Vec<T}/// Maps provider usage onto the established flow completion wire shape.-pub(crate) fn usage_to_json(usage: &Option<crate::inference::provider::BilledUsage>) -> Value {+pub(crate) fn usage_to_json(usage: &Option<tinyinference_llm::usage::BilledUsage>) -> Value {match usage {None => Value::Null,Some(usage) => json!({diff --git a/crates/openhuman-core/src/flows/caps_host/prompt_tests.rs b/crates/openhuman-core/src/flows/caps_host/prompt_tests.rsindex 78dfaba2e5..5666de8778 100644--- a/crates/openhuman-core/src/flows/caps_host/prompt_tests.rs+++ b/crates/openhuman-core/src/flows/caps_host/prompt_tests.rs@@ -1,5 +1,5 @@use super::*;-use crate::inference::provider::BilledUsage;+use tinyinference_llm::usage::BilledUsage;/// The flow `agent`/`llm` node result exposes usage under these exact keys;/// they are a contract with saved flows, so pin the literal JSON.diff --git a/crates/openhuman-core/src/inference/reasoning_tests.rs b/crates/openhuman-core/src/inference/reasoning_tests.rsindex 7efffd319b..343dc3217d 100644--- a/crates/openhuman-core/src/inference/reasoning_tests.rs+++ b/crates/openhuman-core/src/inference/reasoning_tests.rs@@ -215,7 +215,7 @@ fn root_turn_reasoning_reserves_output_room_with_a_budget() {let reasoning = turn_reasoning_for(&ctx,None,- Some(crate::inference::provider::AGENT_TURN_MAX_OUTPUT_TOKENS),+ Some(crate::agent::tinyagents::turn_policy::AGENT_TURN_MAX_OUTPUT_TOKENS),);set_thread_effort(&crate::core::runtime::DispatchCtx::ambient(), thread, None);assert_eq!(diff --git a/crates/openhuman-core/src/platform/cost/global.rs b/crates/openhuman-core/src/platform/cost/global.rsindex 2810980444..3119c5dc0e 100644--- a/crates/openhuman-core/src/platform/cost/global.rs+++ b/crates/openhuman-core/src/platform/cost/global.rs@@ -21,7 +21,7 @@ use parking_lot::RwLock;use crate::config::CostConfig;use crate::core::runtime::DispatchCtx;-use crate::inference::provider::types::BilledUsage;+use tinyinference_llm::usage::BilledUsage;use super::tracker::CostTracker;use super::types::{CostSource, TokenUsage, UsageScope};diff --git a/crates/openhuman-core/src/platform/cost/report_tests.rs b/crates/openhuman-core/src/platform/cost/report_tests.rsindex aa5c6173d5..b34aa9f3fd 100644--- a/crates/openhuman-core/src/platform/cost/report_tests.rs+++ b/crates/openhuman-core/src/platform/cost/report_tests.rs@@ -277,7 +277,7 @@ fn a_model_switch_in_a_thread_is_not_a_cold_call() {#[test]fn an_estimated_cost_lands_in_estimated_usd_not_charged() {- use crate::inference::provider::BilledUsage;+ use tinyinference_llm::usage::BilledUsage;let estimated = BilledUsage::from_counts(100, 10).with_estimated_usd(0.25);let usage = crate::platform::cost::global::build_token_usage("model/a", &estimated).unwrap();assert_eq!(usage.cost_source, CostSource::Estimated);diff --git a/crates/openhuman-core/src/threads/ops/usage.rs b/crates/openhuman-core/src/threads/ops/usage.rsindex 42183542f1..66f7d5c256 100644--- a/crates/openhuman-core/src/threads/ops/usage.rs+++ b/crates/openhuman-core/src/threads/ops/usage.rs@@ -209,7 +209,7 @@ fn recorded_cost(let estimate = model.and_then(|model| {crate::agent::cost::estimate_call_cost_usd(model,- &crate::inference::provider::BilledUsage::from_counts(+ &tinyinference_llm::usage::BilledUsage::from_counts(split.unpriced_input_tokens,split.unpriced_output_tokens,)