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(agent): update tinyagents usage and logic
Steven Enamakel7e0df10cb2cb
diff --git a/crates/openhuman-core/src/agent/agent_tests.rs b/crates/openhuman-core/src/agent/agent_tests.rsindex e1ac9f2b5d..5e21980254 100644--- a/crates/openhuman-core/src/agent/agent_tests.rs+++ b/crates/openhuman-core/src/agent/agent_tests.rs@@ -26,10 +26,10 @@use crate::agent::session_host::OpenHumanSessionHost;use crate::config::AgentConfig;-use tinyinference_llm::model::ChatResponse;use anyhow::Result;use async_trait::async_trait;use std::sync::{Arc, Mutex};+use tinyinference_llm::model::ChatResponse;use tinyinference_llm::model::{ChatModel, ModelProfile, ModelRequest, ModelResponse};use tinytools::{Tool, ToolResult};use tinytools_agent::dialect::NativeToolCall;@@ -87,11 +87,9 @@ impl ChatModel<()> for ScriptedProvider {} else {guard.remove(0)};- Ok(- tinyinference_llm::model::response_to_model_response(- &response, &request,- ),- )+ Ok(tinyinference_llm::model::response_to_model_response(+ &response, &request,+ ))}}diff --git a/crates/openhuman-core/src/agent/agent_turn_loop_nudge_tests.rs b/crates/openhuman-core/src/agent/agent_turn_loop_nudge_tests.rsindex 2407339e07..938961edfc 100644--- a/crates/openhuman-core/src/agent/agent_turn_loop_nudge_tests.rs+++ b/crates/openhuman-core/src/agent/agent_turn_loop_nudge_tests.rs@@ -54,11 +54,9 @@ impl ChatModel<()> for RecordingProvider {guard.remove(0)}};- Ok(- tinyinference_llm::model::response_to_model_response(- &response, &request,- ),- )+ Ok(tinyinference_llm::model::response_to_model_response(+ &response, &request,+ ))}}diff --git a/crates/openhuman-core/src/agent/cost.rs b/crates/openhuman-core/src/agent/cost.rsindex 108c828da9..b708834a45 100644--- a/crates/openhuman-core/src/agent/cost.rs+++ b/crates/openhuman-core/src/agent/cost.rs@@ -16,8 +16,8 @@//! 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 tinyinference_llm::usage::BilledUsage;use tinyagents_harness::cost::{CallCost, CallUsage};+use tinyinference_llm::usage::BilledUsage;/// Whether a model names an explicitly free OpenRouter variant.pub(crate) fn is_free_model(model: &str) -> bool {diff --git a/crates/openhuman-core/src/agent/harness/graph.rs b/crates/openhuman-core/src/agent/harness/graph.rsindex 02dad590e4..b4aa31cd83 100644--- a/crates/openhuman-core/src/agent/harness/graph.rs+++ b/crates/openhuman-core/src/agent/harness/graph.rs@@ -179,7 +179,9 @@ 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::agent::tinyagents::turn_policy::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 258ef8e883..0913a350bd 100644--- a/crates/openhuman-core/src/agent/session_host/driver.rs+++ b/crates/openhuman-core/src/agent/session_host/driver.rs@@ -212,7 +212,9 @@ impl SessionDriver<OpenHumanRunContext> for OpenHumanSessionDriver {message_run_queue: None,early_exit_tools: &["ask_user_clarification"],pause_at_cap: true,- max_output_tokens: Some(crate::agent::tinyagents::turn_policy::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/session_host/driver/grounded_close.rs b/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rsindex 27d915dbef..d275146ab3 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@@ -15,6 +15,7 @@ use tinytools_agent::dialect::ToolDialect;use tinyagents_harness::middleware::wrap_harness_instruction;+use crate::agent::tinyagents::turn_policy::AGENT_TURN_MAX_OUTPUT_TOKENS;use crate::agent::{session_host::turn_checkpoint::{self, build_deterministic_checkpoint, build_deterministic_final_summary_with_cause,@@ -24,7 +25,6 @@ use crate::agent::{tinyagents::{SupplementalTrace, TinyagentsTurnOutcome, TurnModelSource},};use tinyinference_llm::usage::BilledUsage;-use crate::agent::tinyagents::turn_policy::AGENT_TURN_MAX_OUTPUT_TOKENS;/// Accounting from model calls performed after the harness loop has ended.#[derive(Default)]diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs b/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rsindex ee52de7ad5..67d4f31822 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs@@ -1,11 +1,11 @@//! OpenHuman billing adapter for TinyAgents' cap-hit checkpoint summary.-use tinyinference_llm::usage::BilledUsage;use std::sync::{Arc, Mutex};use tinyagents_harness::summarization::CapToolResult;use tinyagents_orchestration::subagent::{summarize_at_cap, CapSummaryModel};use tinyinference_llm::message::Message;use tinyinference_llm::model::{ChatModel, ModelRequest};+use tinyinference_llm::usage::BilledUsage;/// The provider usage from a summary call, charged by the host after the owner/// API applies its shared digest and fallback policy.diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rsindex f1d47c5257..c3c4354b1e 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs@@ -21,8 +21,8 @@ use crate::agent::subagent_host::types::{SubagentMode, SubagentRunError, SubagentRunOptions, SubagentRunOutcome,};use crate::agent::tinyagents::budget::MAX_SPAWN_DEPTH;-use crate::agent_registry::host_definition::{AgentDefinition, AgentDefinitionRegistry};use crate::agent::tinyagents::turn_policy::AGENT_TURN_MAX_OUTPUT_TOKENS;+use crate::agent_registry::host_definition::{AgentDefinition, AgentDefinitionRegistry};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 964c528059..56d0d14883 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs@@ -272,17 +272,16 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>.as_ref().filter(|_| !response.served_from_cache){- let host_usage =- tinyinference_llm::usage::usage_info_from_response(response)- .unwrap_or(- tinyinference_llm::usage::BilledUsage::from_counts(- usage.input_tokens,- usage.output_tokens,- )- .with_cached_input_tokens(usage.cache_read_tokens)- .with_cache_creation_tokens(usage.cache_creation_tokens)- .with_reasoning_tokens(usage.reasoning_tokens),- );+ let host_usage = tinyinference_llm::usage::usage_info_from_response(response)+ .unwrap_or(+ tinyinference_llm::usage::BilledUsage::from_counts(+ usage.input_tokens,+ usage.output_tokens,+ )+ .with_cached_input_tokens(usage.cache_read_tokens)+ .with_cache_creation_tokens(usage.cache_creation_tokens)+ .with_reasoning_tokens(usage.reasoning_tokens),+ );// Use the host's per-call pricing helper whenever the provider// omitted an authoritative amount. `route` is preferred over a// construction-time model because it preserves fallback pricing.diff --git a/crates/openhuman-core/src/agent/tinyagents/mod.rs b/crates/openhuman-core/src/agent/tinyagents/mod.rsindex de00a9e06a..e3ea115de8 100644--- a/crates/openhuman-core/src/agent/tinyagents/mod.rs+++ b/crates/openhuman-core/src/agent/tinyagents/mod.rs@@ -66,10 +66,10 @@ pub(crate) use crate::agent::message_convert::chat_message_to_message;#[cfg(feature = "flows")]pub(crate) use crate::agent::message_convert::ta_call_to_oh_call;-pub(crate) use thread_reasoning::apply_requested_effort;pub use crate::inference::turn_models::TurnModelSource;pub(crate) use observability::SubagentScope;pub(crate) use supplemental_trace::SupplementalTrace;+pub(crate) use thread_reasoning::apply_requested_effort;pub(crate) use turn_exec::TurnSpec;pub(crate) use turn_exec_native::NativeSubagentRunContext;#[cfg(test)]diff --git a/crates/openhuman-core/src/agent/tinyagents/observability/event_bridge.rs b/crates/openhuman-core/src/agent/tinyagents/observability/event_bridge.rsindex a44e9aef4b..5da5235bd5 100644--- a/crates/openhuman-core/src/agent/tinyagents/observability/event_bridge.rs+++ b/crates/openhuman-core/src/agent/tinyagents/observability/event_bridge.rs@@ -9,8 +9,8 @@ use tokio::sync::mpsc::Sender;use tinyinference_llm::usage::Usage;-use tinyinference_llm::usage::BilledUsage;use crate::progress::AgentProgress;+use tinyinference_llm::usage::BilledUsage;use tinytools::humanize_tool_name;use super::bridge_types::{ProviderUsageCarry, SubagentScope, ToolFailureMap, ToolNameMap};diff --git a/crates/openhuman-core/src/agent/tinyagents/thread_reasoning.rs b/crates/openhuman-core/src/agent/tinyagents/thread_reasoning.rsindex 911d824dd4..c030ab613d 100644--- a/crates/openhuman-core/src/agent/tinyagents/thread_reasoning.rs+++ b/crates/openhuman-core/src/agent/tinyagents/thread_reasoning.rs@@ -56,8 +56,10 @@ pub(crate) fn apply_requested_effort({None} else {- Some(ReasoningEffort::parse(trimmed)- .ok_or_else(|| format!("unknown reasoning_effort '{trimmed}'"))?)+ Some(+ ReasoningEffort::parse(trimmed)+ .ok_or_else(|| format!("unknown reasoning_effort '{trimmed}'"))?,+ )};set_thread_effort(ctx, thread_id, requested);@@ -67,4 +69,3 @@ pub(crate) fn apply_requested_effort(pub(crate) fn parse_reasoning_effort(raw: &str) -> Option<ReasoningEffort> {ReasoningEffort::parse(raw)}-diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rs b/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rsindex 13f20c8052..34dfae2024 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rs@@ -180,9 +180,7 @@ pub(super) fn install_turn_middleware(let usage_carry = provider_usage_carry.clone();harness.push_model_middleware(Arc::new(tinyagents_harness::middleware::library::UsageCarryMiddleware::new(move |response| {- if let Some(usage) =- tinyinference_llm::usage::usage_info_from_response(response)- {+ if let Some(usage) = tinyinference_llm::usage::usage_info_from_response(response) {usage_carry.lock().unwrap_or_else(|poisoned| poisoned.into_inner())diff --git a/crates/openhuman-core/src/inference/ops/models.rs b/crates/openhuman-core/src/inference/ops/models.rsindex 0d0e573b08..e856f6c043 100644--- a/crates/openhuman-core/src/inference/ops/models.rs+++ b/crates/openhuman-core/src/inference/ops/models.rs@@ -122,4 +122,3 @@ pub async fn inference_list_models(provider_id: &str) -> Result<Outcome<Value>,}result}-diff --git a/crates/openhuman-core/src/inference/ops/oauth.rs b/crates/openhuman-core/src/inference/ops/oauth.rsindex 48d3e45832..f9a9a1e138 100644--- a/crates/openhuman-core/src/inference/ops/oauth.rs+++ b/crates/openhuman-core/src/inference/ops/oauth.rs@@ -110,4 +110,3 @@ pub async fn inference_openai_oauth_disconnect(config: &Config) -> Result<Outcom}result}-diff --git a/crates/openhuman-core/src/inference/ops/sentiment.rs b/crates/openhuman-core/src/inference/ops/sentiment.rsindex d7834f7ff3..2134cfd6f0 100644--- a/crates/openhuman-core/src/inference/ops/sentiment.rs+++ b/crates/openhuman-core/src/inference/ops/sentiment.rs@@ -53,4 +53,3 @@ pub async fn inference_analyze_sentiment(}result}-diff --git a/crates/openhuman-core/src/inference/ops/status.rs b/crates/openhuman-core/src/inference/ops/status.rsindex 2fc4ad02fa..54bc2913c1 100644--- a/crates/openhuman-core/src/inference/ops/status.rs+++ b/crates/openhuman-core/src/inference/ops/status.rs@@ -189,5 +189,5 @@ pub async fn inference_diagnostics(config: &Config) -> Result<Outcome<Value>, St}#[cfg(test)]-#[path = "ops_tests.rs"]+#[path = "../ops_tests.rs"]mod tests;diff --git a/crates/openhuman-core/src/inference/reasoning.rs b/crates/openhuman-core/src/inference/reasoning.rsindex aefc60b583..05844d31a3 100644--- a/crates/openhuman-core/src/inference/reasoning.rs+++ b/crates/openhuman-core/src/inference/reasoning.rs@@ -64,17 +64,15 @@ pub(crate) fn turn_reasoning_for(let dispatch = ctx.dispatch_ctx();let reasoning = if let Some(thread_id) = ctx.thread_id.as_deref() {- crate::agent::tinyagents::thread_reasoning::store(&dispatch)- .reasoning_for_turn(- Some(&tinyagents_harness::ids::ThreadId::new(thread_id)),- max_output_tokens,- )+ crate::agent::tinyagents::thread_reasoning::store(&dispatch).reasoning_for_turn(+ Some(&tinyagents_harness::ids::ThreadId::new(thread_id)),+ max_output_tokens,+ )} else {None}.or_else(|| {- reasoning_for_config(config?)- .map(|reasoning| reasoning.with_output_room(max_output_tokens))+ reasoning_for_config(config?).map(|reasoning| reasoning.with_output_room(max_output_tokens))});if let Some(reasoning) = reasoning.as_ref() {