Skip to content

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

feat(embed): add physical dispatch observer to completer

Steven Enamakel1bb1bd38e76f
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops.rs b/crates/openhuman-core/src/inference/host_runtime/ops.rs
index 3b90031282..b37d848af0 100644
--- a/crates/openhuman-core/src/inference/host_runtime/ops.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/ops.rs
@@ -17,7 +17,7 @@ pub use agent_chat::{
agent_chat, agent_chat_for, agent_chat_reply_for, agent_chat_simple, AgentChatEnv,
AgentChatReply, AgentChatTarget,
};
-pub use complete_once::{complete_once, CompletionEndpoint};
+pub use complete_once::{complete_once, complete_once_observed, CompletionEndpoint};
pub use runtime_ops::{
local_ai_prompt, local_ai_status, local_ai_summarize, local_ai_transcribe,
local_ai_transcribe_bytes, local_ai_tts, local_ai_vision_prompt,
diff --git a/crates/openhuman-embed/src/complete.rs b/crates/openhuman-embed/src/complete.rs
index 5b6cf9b467..4c9f183096 100644
--- a/crates/openhuman-embed/src/complete.rs
+++ b/crates/openhuman-embed/src/complete.rs
@@ -433,6 +433,7 @@ pub struct Completer {
headers: Vec<(String, String)>,
timeout: Option<Duration>,
observer: Option<Arc<dyn CompletionObserver>>,
+ physical_observer: Option<Arc<dyn tinyagents_harness::observability::PhysicalDispatchObserver>>,
cancellation: crate::cancellation::Cancellation,
budget: Option<crate::budget::ModelBudget>,
}
@@ -456,6 +457,7 @@ impl Completer {
route,
timeout: None,
observer: None,
+ physical_observer: None,
cancellation: Default::default(),
budget: None,
}
@@ -495,6 +497,15 @@ impl Completer {
self
}
+ /// Observe each admitted provider dispatch without request or response content.
+ pub fn physical_observer(
+ mut self,
+ observer: Arc<dyn tinyagents_harness::observability::PhysicalDispatchObserver>,
+ ) -> Self {
+ self.physical_observer = Some(observer);
+ self
+ }
+
/// Run `request` once.
///
/// # Errors
@@ -602,10 +613,11 @@ impl Completer {
call: budget.call,
});
// The spend ledger is an explicit argument of the call, not an ambient scope.
- let call = openhuman_core::inference::host_runtime::ops::complete_once(
+ let call = openhuman_core::inference::host_runtime::ops::complete_once_observed(
&endpoint,
request.into_wire(),
budget.as_ref(),
+ self.physical_observer.clone(),
);
let started = std::time::Instant::now();
let response = call.await.map_err(|message| {