Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(tinyagents): move supplemental call projection into event bridge

Steven Enamakel3946ece77ed9
diff --git a/crates/openhuman-core/src/agent/tinyagents/observability/event_bridge.rs b/crates/openhuman-core/src/agent/tinyagents/observability/event_bridge.rs
index e4871a5cc3..aa35ab5814 100644
--- a/crates/openhuman-core/src/agent/tinyagents/observability/event_bridge.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/observability/event_bridge.rs
@@ -14,7 +14,7 @@ use crate::progress::AgentProgress;
use tinytools::humanize_tool_name;
use super::bridge_types::{ProviderUsageCarry, SubagentScope, ToolFailureMap, ToolNameMap};
-use tinyagents_harness::events::{CallDedupe, IterationCursor, OrderedSender};
+use tinyagents_harness::events::{CallDedupe, EventRecord, IterationCursor, OrderedSender};
#[derive(Default)]
pub(super) struct BridgeState {
@@ -125,6 +125,34 @@ pub(crate) struct OpenhumanEventBridge {
pub(super) dispatch: crate::core::runtime::DispatchCtx,
}
+impl OpenhumanEventBridge {
+ /// Supplemental host calls belong in the durable trace, but are not
+ /// agent-loop iterations or live wallet updates.
+ pub(super) fn project_supplemental(&self, record: &EventRecord) -> bool {
+ match &record.event {
+ AgentEvent::ModelStarted { call_id, .. }
+ if call_id.as_str().contains("-host-supplemental-") =>
+ {
+ self.supplemental_call_active.store(true, Ordering::SeqCst);
+ true
+ }
+ AgentEvent::UsageRecorded { .. }
+ if self.supplemental_call_active.load(Ordering::SeqCst) =>
+ {
+ true
+ }
+ AgentEvent::ModelCompleted { call_id, .. }
+ | AgentEvent::ModelFailed { call_id, .. }
+ if call_id.as_str().contains("-host-supplemental-") =>
+ {
+ self.supplemental_call_active.store(false, Ordering::SeqCst);
+ true
+ }
+ _ => false,
+ }
+ }
+}
+
impl OpenhumanEventBridge {
/// Build a parent-scoped bridge for `model`.
pub(crate) fn new(
diff --git a/crates/openhuman-core/src/agent/tinyagents/observability/event_projection.rs b/crates/openhuman-core/src/agent/tinyagents/observability/event_projection.rs
index 5de96ca5b5..7aff746e84 100644
--- a/crates/openhuman-core/src/agent/tinyagents/observability/event_projection.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/observability/event_projection.rs
@@ -709,38 +709,6 @@ impl EventListener for OpenhumanEventBridge {
}
}
-impl OpenhumanEventBridge {
- /// Supplemental host calls belong in the durable trace, but they are not
- /// agent-loop iterations or live wallet updates.
- fn project_supplemental(&self, record: &EventRecord) -> bool {
- 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);
- true
- }
- AgentEvent::UsageRecorded { .. }
- if self
- .supplemental_call_active
- .load(std::sync::atomic::Ordering::SeqCst) =>
- {
- true
- }
- AgentEvent::ModelCompleted { call_id, .. }
- | AgentEvent::ModelFailed { call_id, .. }
- if call_id.as_str().contains("-host-supplemental-") =>
- {
- self.supplemental_call_active
- .store(false, std::sync::atomic::Ordering::SeqCst);
- true
- }
- _ => false,
- }
- }
-}
-
impl OpenhumanEventBridge {
/// The "unavailable" label/detail pair for a call the crate answered as an
/// unknown tool, or `None` for an ordinary call.