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(inference): move turn model types out of tinyagents
Steven Enamakel81b95d664aa2
diff --git a/crates/openhuman-core/src/agent/agent_tests.rs b/crates/openhuman-core/src/agent/agent_tests.rsindex 3584d9ded6..76c6b8d7d8 100644--- a/crates/openhuman-core/src/agent/agent_tests.rs+++ b/crates/openhuman-core/src/agent/agent_tests.rs@@ -87,7 +87,7 @@ impl ChatModel<()> for ScriptedProvider {} else {guard.remove(0)};- Ok(crate::agent::tinyagents::model::native_model_response_for_request(&response, &request))+ Ok(crate::inference::provider::model::native_model_response_for_request(&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 0a6436c733..9a613ec8c5 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,7 +54,7 @@ impl ChatModel<()> for RecordingProvider {guard.remove(0)}};- Ok(crate::agent::tinyagents::model::native_model_response_for_request(&response, &request))+ Ok(crate::inference::provider::model::native_model_response_for_request(&response, &request))}}diff --git a/crates/openhuman-core/src/agent/cost_tests.rs b/crates/openhuman-core/src/agent/cost_tests.rsindex 3cf7e4a903..6be5acc672 100644--- a/crates/openhuman-core/src/agent/cost_tests.rs+++ b/crates/openhuman-core/src/agent/cost_tests.rs@@ -10,7 +10,7 @@ fn counts(input: u64, output: u64, cached: u64) -> BilledUsage {/// the harness `StopHookMetrics` impl, priced through the catalog lookup.fn record(turn: &mut tinyagents_harness::cost::TurnCost, model: &str, usage: &BilledUsage) {use tinyagents_hooks::stop::StopHookMetrics as _;- let response = crate::agent::tinyagents::model::native_model_response_for_request(+ let response = crate::inference::provider::model::native_model_response_for_request(&crate::inference::provider::ChatResponse {text: Some("ok".into()),usage: Some(*usage),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 e1b848003c..030262b8af 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@@ -391,7 +391,7 @@ async fn completion(};return (selected,- crate::agent::tinyagents::model::usage_info_from_response(&response),+ crate::inference::provider::model::usage_info_from_response(&response),);}ModelStreamItem::Failed(_) | ModelStreamItem::ProviderFailed(_) => {diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs b/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rsindex 63ced1b11a..fc8458be29 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs@@ -54,7 +54,7 @@ impl SubagentCheckpoint {let request = ModelRequest::new(summary_input).with_max_tokens(self.max_output_tokens);match self.chat_model.invoke(&(), request).await {Ok(resp) => {- let usage = crate::agent::tinyagents::model::usage_info_from_response(&resp);+ let usage = crate::inference::provider::model::usage_info_from_response(&resp);let raw = resp.text();let (prose, _) = tinytools_agent::parse_tool_calls(&raw);let text = if prose.trim().is_empty() {diff --git a/crates/openhuman-core/src/agent/tinyagents/context_wiring.rs b/crates/openhuman-core/src/agent/tinyagents/context_wiring.rsindex e0691aed13..c918540e0e 100644--- a/crates/openhuman-core/src/agent/tinyagents/context_wiring.rs+++ b/crates/openhuman-core/src/agent/tinyagents/context_wiring.rs@@ -19,7 +19,7 @@ use tinyagents_harness::summarization::{use crate::agent::tinyagents::host::OpenHumanRunContext;use crate::agent::tinyagents::memory_summarizer::MemoryRecallSummarizer;-use crate::agent::tinyagents::model::TurnChatModel;+use crate::inference::provider::model::TurnChatModel;use tinyagents_harness::turn_outcome::ToolOutcomeSink;/// Fractions of a capped turn's model-call budget at which the model is tolddiff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rsindex ae501bba7e..577eccc29b 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs@@ -298,7 +298,7 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>guard.output_tokens += usage.output_tokens;guard.cached_input_tokens += usage.cache_read_tokens;let host_usage =- crate::agent::tinyagents::model::usage_info_from_response(response).unwrap_or(+ crate::inference::provider::model::usage_info_from_response(response).unwrap_or(crate::inference::provider::BilledUsage::from_counts(usage.input_tokens,usage.output_tokens,diff --git a/crates/openhuman-core/src/agent/tinyagents/mod.rs b/crates/openhuman-core/src/agent/tinyagents/mod.rsindex 2f6b8c6f6a..560a7a4062 100644--- a/crates/openhuman-core/src/agent/tinyagents/mod.rs+++ b/crates/openhuman-core/src/agent/tinyagents/mod.rs@@ -54,7 +54,7 @@ pub(crate) mod stop_hooks;pub(crate) mod tool_registration;mod turn_exec;mod turn_middleware;-mod turn_model_resolver;+pub(crate) mod turn_model_resolver;mod turn_outcome;mod turn_plan;mod turn_policy;diff --git a/crates/openhuman-core/src/agent/tinyagents/observability/bridge_types.rs b/crates/openhuman-core/src/agent/tinyagents/observability/bridge_types.rsindex 6620b7c416..59bbcb6e8a 100644--- a/crates/openhuman-core/src/agent/tinyagents/observability/bridge_types.rs+++ b/crates/openhuman-core/src/agent/tinyagents/observability/bridge_types.rs@@ -25,7 +25,7 @@ pub struct SubagentScope {/// writes it when a tool call *starts* (the crate `ToolDelta` has no `tool_name`/// field, so the start-event/name half of the tool-arg contract can't ride the/// crate stream and stays on the out-of-band forwarder path — see-/// [`super::model::ThinkingForwarder`]). The bridge reads it to label the+/// [`crate::inference::provider::model::ThinkingForwarder`]). The bridge reads it to label the/// incremental tool-argument fragments it now projects off the crate stream/// (`MessageDelta.tool_call`), preserving the UI's `ToolCallArgsDelta`/// `tool_name` contract without the forwarder emitting those fragments itself.diff --git a/crates/openhuman-core/src/agent/tinyagents/routes.rs b/crates/openhuman-core/src/agent/tinyagents/routes.rsindex 6a722dd775..69cf114636 100644--- a/crates/openhuman-core/src/agent/tinyagents/routes.rs+++ b/crates/openhuman-core/src/agent/tinyagents/routes.rs@@ -177,7 +177,7 @@ impl ModelMiddleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>/// 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+/// ([`usage_info_from_response`](crate::inference::provider::model::usage_info_from_response)) — and/// pushes it onto the shared [`ProviderUsageCarry`](super::observability::ProviderUsageCarry)/// the [`OpenhumanEventBridge`](super::OpenhumanEventBridge) drains on/// `UsageRecorded`.@@ -215,7 +215,7 @@ impl ModelMiddleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>) -> tinyagents_harness::Result<MiddlewareModelOutcome> {let outcome = next.run(ctx, state, request).await?;let response = outcome.into_response();- if let Some(usage) = super::model::usage_info_from_response(&response) {+ if let Some(usage) = crate::inference::provider::model::usage_info_from_response(&response) {self.carry.lock().unwrap_or_else(|p| p.into_inner())diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rsindex 97be734966..80072f3e52 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs@@ -28,7 +28,7 @@ use crate::agent::tinyagents::tool_registration::capability_diagnostics;use crate::agent::tinyagents::turn_middleware::{TurnMiddlewareInputs, TurnWiring, install_turn_middleware,};-use crate::agent::tinyagents::turn_models::TurnModels;+use crate::inference::turn_models::TurnModels;use crate::agent::tinyagents::turn_outcome::TinyagentsTurnOutcome;use crate::agent::tinyagents::turn_plan::{OpenHumanTurnPlanner, enforce_registry_diagnostics, turn_models_for_plan, turn_run_policy,@@ -173,7 +173,7 @@ async fn drive_turn(let turn_models = turn_models.with_budget(run_context.model_budget.as_ref());let hosted_model_resolver = hosted_root.as_ref().map(|_| {Arc::new(- crate::agent::tinyagents::turn_models::TurnModelResolver::from_turn_models(+ crate::inference::turn_models::TurnModelResolver::from_turn_models(&turn_models,),) as Arc<dyn tinyagents_harness::host::ModelResolver<()>>@@ -198,7 +198,7 @@ async fn drive_turn(deterministic_cacheable,is_local,run_context.tool_dialect,- crate::agent::tinyagents::reasoning::turn_reasoning_for(+ crate::inference::reasoning::turn_reasoning_for(&run_context,hosted_root.as_ref().map(|(base, _)| base.config.as_ref()),max_output_tokens,diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rs b/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rsindex ed2155d504..5a3ec2133b 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rs@@ -34,7 +34,7 @@ use crate::agent::tinyagents::context_wiring::install_context_ladder;use crate::agent::tinyagents::host::OpenHumanRunContext;use crate::agent::tinyagents::middleware;use crate::agent::tinyagents::middleware::turn_context::TurnContextMiddleware;-use crate::agent::tinyagents::model::TurnChatModel;+use crate::inference::provider::model::TurnChatModel;use crate::agent::tinyagents::observability::{ProviderUsageCarry, SubagentScope, ToolFailureMap};use crate::agent::tinyagents::routes;use crate::agent::tinyagents::stop_hooks;diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_plan.rs b/crates/openhuman-core/src/agent/tinyagents/turn_plan.rsindex 8df5717329..5170be3912 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_plan.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_plan.rs@@ -20,7 +20,7 @@ use tinyagents_runtime::{DriverRequest, RuntimeError};use tinyinference_llm::model::ErrorSlotModel;use crate::agent::tinyagents::host::OpenHumanRunContext;-use crate::agent::tinyagents::model::TurnChatModel;+use crate::inference::provider::model::TurnChatModel;use crate::agent::tinyagents::routes;use crate::agent::tinyagents::tool_registration::host_tool_set_builder;use crate::agent::tinyagents::turn_policy::run_policy_for_provider;diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_plan_tests.rs b/crates/openhuman-core/src/agent/tinyagents/turn_plan_tests.rsindex 009b343a17..d6c409c8b2 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_plan_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_plan_tests.rs@@ -3,7 +3,7 @@use super::*;use crate::agent::tinyagents::TurnModelSource;-use crate::agent::tinyagents::turn_models::TurnModels;+use crate::inference::turn_models::TurnModels;use async_trait::async_trait;use tinyagents_harness::turn_policy::{DEFAULT_MODEL_CALL_TIMEOUT_SECS, LOCAL_MODEL_CALL_TIMEOUT_SECS,diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/prompt.rs b/crates/openhuman-core/src/flows/tinyflows/caps/prompt.rsindex 8797ee1242..30e9dc79cb 100644--- a/crates/openhuman-core/src/flows/tinyflows/caps/prompt.rs+++ b/crates/openhuman-core/src/flows/tinyflows/caps/prompt.rs@@ -65,7 +65,7 @@ pub(crate) fn model_response_to_completion_value(.map(crate::agent::tinyagents::ta_call_to_oh_call).collect::<Vec<_>>(),"usage": usage_to_json(- &crate::agent::tinyagents::model::usage_info_from_response(response)+ &crate::inference::provider::model::usage_info_from_response(response)),"reasoning_content": tinyagents_runtime::transcript::reasoning_from_content(&response.message.contentdiff --git a/crates/openhuman-core/src/inference/provider/model.rs b/crates/openhuman-core/src/inference/provider/model.rsindex 19de9cda11..f85f03ce44 100644--- a/crates/openhuman-core/src/inference/provider/model.rs+++ b/crates/openhuman-core/src/inference/provider/model.rs@@ -9,9 +9,9 @@ use tinyinference_llm::usage::{ProviderUsageReport, recover_usage};use crate::inference::provider::{BilledUsage, ChatResponse};-pub(super) type TurnChatModel = Arc<dyn ChatModel<()>>;-pub(super) type TierRoutes = Vec<(String, TurnChatModel)>;-pub(super) type BuiltTurnModels = (TurnChatModel, TierRoutes, TurnChatModel);+pub(crate) type TurnChatModel = Arc<dyn ChatModel<()>>;+pub(crate) type TierRoutes = Vec<(String, TurnChatModel)>;+pub(crate) type BuiltTurnModels = (TurnChatModel, TierRoutes, TurnChatModel);/// Build a [`PFormatRegistry`](tinytools_agent::PFormatRegistry)/// from the tool schemas advertised on a [`ModelRequest`] (issue #4465).diff --git a/crates/openhuman-core/src/inference/provider/openhuman_backend_model_stream_tests.rs b/crates/openhuman-core/src/inference/provider/openhuman_backend_model_stream_tests.rsindex e25340ea1a..f217e772a2 100644--- a/crates/openhuman-core/src/inference/provider/openhuman_backend_model_stream_tests.rs+++ b/crates/openhuman-core/src/inference/provider/openhuman_backend_model_stream_tests.rs@@ -259,7 +259,7 @@ async fn managed_stream_carries_the_backend_charge_to_the_cost_accounting() {]).await;- let billed = crate::agent::tinyagents::model::usage_info_from_response(&response)+ let billed = crate::inference::provider::model::usage_info_from_response(&response).expect("usage reported");assert!(billed.charge_reported,@@ -282,7 +282,7 @@ async fn managed_stream_keeps_a_zero_charge_as_known() {serde_json::json!({ "openhuman": { "billing": { "charged_amount_usd": 0.0 } } }),]).await;- let billed = crate::agent::tinyagents::model::usage_info_from_response(&response)+ let billed = crate::inference::provider::model::usage_info_from_response(&response).expect("usage reported");assert_eq!(crate::agent::cost::call_cost("openrouter/z-ai/glm-5.3-flash", &billed),@@ -299,7 +299,7 @@ async fn managed_stream_without_a_billing_frame_has_no_charge() {serde_json::json!({ "choices": [], "usage": { "prompt_tokens": 10, "completion_tokens": 2, "total_tokens": 12 } }),]).await;- let billed = crate::agent::tinyagents::model::usage_info_from_response(&response)+ let billed = crate::inference::provider::model::usage_info_from_response(&response).expect("usage reported");assert!(!billed.charge_reported);assert_eq!(diff --git a/crates/openhuman-core/src/inference/provider/openhuman_backend_model_usage_tests.rs b/crates/openhuman-core/src/inference/provider/openhuman_backend_model_usage_tests.rsindex 38dda30be1..5e10639fa2 100644--- a/crates/openhuman-core/src/inference/provider/openhuman_backend_model_usage_tests.rs+++ b/crates/openhuman-core/src/inference/provider/openhuman_backend_model_usage_tests.rs@@ -5,7 +5,7 @@ use super::*;/// tokens, and context window — exactly as the legacy legacy model-adapter path did.#[test]fn project_managed_usage_recovers_charged_and_cached() {- use crate::agent::tinyagents::model::usage_info_from_response;+ use crate::inference::provider::model::usage_info_from_response;use tinyinference_llm::message::AssistantMessage;use tinyinference_llm::usage::Usage;@@ -54,7 +54,7 @@ fn project_managed_usage_recovers_charged_and_cached() {/// charged USD — so non-managed/billing-free responses aren't fabricated.#[test]fn project_managed_usage_is_noop_without_envelope() {- use crate::agent::tinyagents::model::usage_info_from_response;+ use crate::inference::provider::model::usage_info_from_response;use tinyinference_llm::message::AssistantMessage;use tinyinference_llm::usage::Usage;diff --git a/crates/openhuman-core/src/inference/turn_models.rs b/crates/openhuman-core/src/inference/turn_models.rsindex 4caccf0619..36d1b8bad0 100644--- a/crates/openhuman-core/src/inference/turn_models.rs+++ b/crates/openhuman-core/src/inference/turn_models.rs@@ -3,10 +3,10 @@use std::sync::Arc;-pub(crate) use super::turn_model_resolver::TurnModelResolver;+pub(crate) use crate::agent::tinyagents::turn_model_resolver::TurnModelResolver;use crate::core::runtime::DispatchCtx;-use crate::agent::tinyagents::model::{BuiltTurnModels, TierRoutes, TurnChatModel};+use crate::inference::provider::model::{BuiltTurnModels, TierRoutes, TurnChatModel};use tinyinference_llm::model::ProfileOverrideModel;use tinyinference_llm::model::{ResolvedModelRoute, RouteRecordingModel};