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
fix(tinyagents): skip usage recording for supplemental host model calls
Steven Enamakel3c7ce291a31a
diff --git a/crates/openhuman-core/src/agent/tinyagents/observability/event_bridge.rs b/crates/openhuman-core/src/agent/tinyagents/observability/event_bridge.rsindex 95905bab84..7a1b286bf8 100644--- a/crates/openhuman-core/src/agent/tinyagents/observability/event_bridge.rs+++ b/crates/openhuman-core/src/agent/tinyagents/observability/event_bridge.rs@@ -2,7 +2,7 @@//! `tinyagents` harness event stream onto openhuman's [`AgentProgress`] +//! cost tracker (issue #4249). See the parent module doc for the overview.-use std::sync::atomic::Ordering;+use std::sync::atomic::{AtomicBool, Ordering};use std::sync::{Arc, Mutex};use tokio::sync::mpsc::Sender;@@ -56,6 +56,11 @@ pub(crate) struct OpenhumanEventBridge {/// model as `{provider_id}.{model}`.pub(super) provider_id: String,pub(super) max_iterations: u32,+ /// Supplemental host repairs are durable trace generations but are not+ /// extra agent-loop iterations or live wallet events. They share this+ /// run-local ordered event sink, so `ModelStarted` brackets the following+ /// `UsageRecorded` and terminal model event synchronously.+ pub(super) supplemental_call_active: AtomicBool,/// `None` for a parent turn; `Some` to emit child-scoped `Subagent*` events.pub(super) scope: Option<SubagentScope>,/// The agent definition the run acts as (its memory identity's agent),@@ -168,6 +173,7 @@ impl OpenhumanEventBridge {model: model.into(),provider_id: provider_id.into(),max_iterations: max_iterations as u32,+ supplemental_call_active: AtomicBool::new(false),scope,definition: std::sync::OnceLock::new(),cursor,diff --git a/crates/openhuman-core/src/agent/tinyagents/observability/event_projection.rs b/crates/openhuman-core/src/agent/tinyagents/observability/event_projection.rsindex 3848a6acea..151722f28e 100644--- a/crates/openhuman-core/src/agent/tinyagents/observability/event_projection.rs+++ b/crates/openhuman-core/src/agent/tinyagents/observability/event_projection.rs@@ -14,6 +14,11 @@ use super::event_bridge::OpenhumanEventBridge;impl EventListener for OpenhumanEventBridge {fn on_event(&self, record: &EventRecord) {match &record.event {+ AgentEvent::ModelStarted { call_id, .. }+ if call_id.as_str().contains("-host-supplemental-") =>+ {+ self.supplemental_call_active.store(true, std::sync::atomic::Ordering::SeqCst);+ }AgentEvent::ModelStarted { .. } => {let iteration = tinyagents_harness::events::advance_iteration(&self.cursor);match &self.scope {@@ -127,7 +132,14 @@ impl EventListener for OpenhumanEventBridge {// `UsageRecorded` carries the authoritative per-call usage and fires// exactly once per model call; prefer it over `ModelCompleted`'s// optional usage to avoid double counting.- AgentEvent::UsageRecorded { usage } => self.record_usage(usage),+ AgentEvent::UsageRecorded { usage } => {+ if !self+ .supplemental_call_active+ .load(std::sync::atomic::Ordering::SeqCst)+ {+ self.record_usage(usage);+ }+ }// Per-call generation telemetry. `ModelCompleted` fires exactly once// per model call, after `UsageRecorded`, and is the only event// carrying the captured request messages (incl. the system prompt)@@ -136,6 +148,12 @@ impl EventListener for OpenhumanEventBridge {// child call carries its owning `subagent_task_id` so the trace// exporter nests the generation under the subagent span (this is// what makes the Context Scout's model calls visible in Langfuse).+ AgentEvent::ModelCompleted {+ call_id,+ ..+ } if call_id.as_str().contains("-host-supplemental-") => {+ self.supplemental_call_active.store(false, std::sync::atomic::Ordering::SeqCst);+ }AgentEvent::ModelCompleted {usage,input,@@ -198,6 +216,11 @@ impl EventListener for OpenhumanEventBridge {cost_usd: call_cost,});}+ AgentEvent::ModelFailed { call_id, .. }+ if call_id.as_str().contains("-host-supplemental-") =>+ {+ self.supplemental_call_active.store(false, std::sync::atomic::Ordering::SeqCst);+ }AgentEvent::CostRecorded { cost } => {tracing::debug!(cost = ?cost,