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(tinyagents): use shared usage carry middleware from harness
Steven Enamakel7acb65f9d364
diff --git a/crates/openhuman-core/src/agent/tinyagents/routes.rs b/crates/openhuman-core/src/agent/tinyagents/routes.rsindex d92e9156d0..e8abd69f0a 100644--- a/crates/openhuman-core/src/agent/tinyagents/routes.rs+++ b/crates/openhuman-core/src/agent/tinyagents/routes.rs@@ -5,13 +5,13 @@ use std::sync::LazyLock;use async_trait::async_trait;use tinyagents_harness::context::RunContext;use tinyagents_harness::events::{AgentEvent, GenerationEnrichment, GenerationPricing};+pub(super) use tinyagents_harness::middleware::library::{+ FallbackObserverMiddleware, RequiredCapabilitiesMiddleware,+};use tinyagents_harness::middleware::{MiddlewareModelOutcome, ModelHandler, ModelMiddleware};use tinyagents_harness::retry::FallbackPolicy;use tinyagents_registry::WorkloadRouter;use tinyinference_llm::model::{CapabilitySet, ModelRequest};-pub(super) use tinyagents_harness::middleware::library::{- FallbackObserverMiddleware, RequiredCapabilitiesMiddleware,-};/// The workload routing table (fallback chains and the vision `image_in` gate)/// projected into the crate [`WorkloadRouter`] from the upstream declarativediff --git a/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rs b/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rsindex a8d877cb89..f51c9ab8bf 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rs@@ -177,9 +177,19 @@ pub(super) fn install_turn_middleware(// 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`.- harness.push_model_middleware(Arc::new(routes::UsageCarryMiddleware::new(- provider_usage_carry.clone(),- )));+ 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) =+ crate::inference::provider::model::usage_info_from_response(response)+ {+ usage_carry+ .lock()+ .unwrap_or_else(|poisoned| poisoned.into_inner())+ .push_back(usage);+ }+ }),+ ));// Route audit capture is a typed run-context concern. The canonical// TinyInference decorator attached in `turn_models` stamps the successfuldiff --git a/crates/openhuman-core/src/agent/tools/plan_exit_tests.rs b/crates/openhuman-core/src/agent/tools/plan_exit_tests.rsindex cb6f6866c7..8d2a9af33c 100644--- a/crates/openhuman-core/src/agent/tools/plan_exit_tests.rs+++ b/crates/openhuman-core/src/agent/tools/plan_exit_tests.rs@@ -1,8 +1,8 @@use super::*;use crate::agent::tools::{PlanExitTool, PLAN_EXIT_MARKER};use crate::plan_review::PlanReviewResolution;-use tinytools::{PermissionLevel, Tool, ToolCallOptions, ToolRunContext};use serde_json::json;+use tinytools::{PermissionLevel, Tool, ToolCallOptions, ToolRunContext};struct ThreadContext(&'static str);impl ToolRunContext for ThreadContext {