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(tinyagents): add observer support to budget model wrapping
Steven Enamakel1d65c521167d
diff --git a/crates/openhuman-core/src/agent/tinyagents/budget.rs b/crates/openhuman-core/src/agent/tinyagents/budget.rsindex 7e29c8362e..0e8c3dd0a7 100644--- a/crates/openhuman-core/src/agent/tinyagents/budget.rs+++ b/crates/openhuman-core/src/agent/tinyagents/budget.rs@@ -31,7 +31,17 @@ impl ModelBudget {/// Wrap the model with TinyAgents' shared physical-call budget engine.pub(crate) fn wrap(&self, model: Arc<dyn ChatModel<()>>) -> Arc<dyn ChatModel<()>> {- tinyagents_harness::cost::ModelBudget::new(self.ledger.clone(), self.call).wrap_model(model)+ self.wrap_with_observer(model, None)+ }++ /// Wrap the model with budget accounting and an optional physical observer.+ pub(crate) fn wrap_with_observer(+ &self,+ model: Arc<dyn ChatModel<()>>,+ observer: Option<Arc<dyn tinyagents_harness::observability::PhysicalDispatchObserver>>,+ ) -> Arc<dyn ChatModel<()>> {+ tinyagents_harness::cost::ModelBudget::new(self.ledger.clone(), self.call)+ .wrap_model_with_observer(model, observer)}}diff --git a/crates/openhuman-core/src/inference/host_runtime/ops/complete_once.rs b/crates/openhuman-core/src/inference/host_runtime/ops/complete_once.rsindex 34c5b38383..7890099e23 100644--- a/crates/openhuman-core/src/inference/host_runtime/ops/complete_once.rs+++ b/crates/openhuman-core/src/inference/host_runtime/ops/complete_once.rs@@ -112,17 +112,19 @@ pub async fn complete_once_observed();let model: std::sync::Arc<dyn ChatModel<()>> = std::sync::Arc::new(model);- let model: std::sync::Arc<dyn ChatModel<()>> = match observer {- Some(observer) => std::sync::Arc::new(- tinyagents_harness::observability::physical_dispatch::ObservedChatModel::new(- model, observer,- ),- ),- None => model,- };- let model = match budget {- Some(budget) => budget.wrap(model),- None => model,+ let model: std::sync::Arc<dyn ChatModel<()>> = match (budget, observer) {+ (Some(budget), observer) => budget.wrap_with_observer(model, observer),+ (None, Some(observer)) => {+ let normalized = std::sync::Arc::new(+ tinyagents_harness::cost::GatewayChargeModel::new(model),+ );+ std::sync::Arc::new(+ tinyagents_harness::observability::physical_dispatch::ObservedChatModel::new(+ normalized, observer,+ ),+ )+ }+ (None, None) => model,};model.invoke(&(), request)