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(embed): simplify dispatch refusal handling and import ordering
Steven Enamakelb512ac469854
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rsindex 69085d1f74..9983223bfe 100644--- a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs+++ b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs@@ -548,9 +548,7 @@ pub async fn agent_chat_reply_for_controlled(..} = target{- agent- .set_untrusted_input(true)- .map_err(anyhow::Error::msg)?;+ agent.set_untrusted_input(true)?;}// A seeded turn replaces resume rather than adding to it.//diff --git a/crates/openhuman-embed/src/turn.rs b/crates/openhuman-embed/src/turn.rsindex 15bff04c06..087e52118c 100644--- a/crates/openhuman-embed/src/turn.rs+++ b/crates/openhuman-embed/src/turn.rs@@ -49,8 +49,8 @@ use openhuman_core::security::turn_origin::AgentTurnOrigin;#[path = "turn_types.rs"]mod types;-pub use types::{Route, TurnOutcome, TurnRequest};pub(crate) use types::{is_safe_endpoint_for_bearer, sanitize_url_for_display};+pub use types::{Route, TurnOutcome, TurnRequest};#[path = "turn_control.rs"]mod control;@@ -175,11 +175,11 @@ impl Turn {pub fn tools(mut self,factory: impl for<'a> Fn(- openhuman_core::agent::TurnContext<'a>,- ) -> openhuman_core::agent::HostTurnTools- + Send- + Sync- + 'static,+ openhuman_core::agent::TurnContext<'a>,+ ) -> openhuman_core::agent::HostTurnTools+ + Send+ + Sync+ + 'static,) -> Self {self.tools = Some(Arc::new(factory));self@@ -617,7 +617,7 @@ async fn dispatch(let turn: futures_box::BoxFuture<'_, Result<AgentReply, CoreError>> =Box::pin(async move {use openhuman_core::inference::host_runtime::ops::{- AgentChatTarget, agent_chat_reply_for_controlled,+ agent_chat_reply_for_controlled, AgentChatTarget,};let mut config = dispatch.load_config()@@ -663,7 +663,7 @@ async fn dispatch(let turn: futures_box::BoxFuture<'_, Result<AgentReply, CoreError>> =Box::pin(async move {use openhuman_core::inference::host_runtime::ops::{- AgentChatTarget, agent_chat_reply_for_controlled,+ agent_chat_reply_for_controlled, AgentChatTarget,};let mut config = inner.config.clone();let route = openhuman_core::config::schema::EphemeralRoute::from_params(@@ -711,21 +711,22 @@ async fn dispatch(spent.reasoning_tokens = report.reasoning_tokens;}}- if let Err(error) = &outcome- && let Some(refusal) =+ if let Err(error) = &outcome {+ if let Some(refusal) =error.downcast_ref::<crate::budget::DispatchRefusal>()- {- return Err(CoreError::DispatchAdmission {- method: AGENT_CHAT,- source: *refusal,- usage: report.usage.map(|spent| crate::complete::CompletionUsage {- input_tokens: spent.input_tokens,- output_tokens: spent.output_tokens,- cached_tokens: spent.cached_tokens,- reasoning_tokens: spent.reasoning_tokens,- cost_usd: spent.cost_usd,- }),- });+ {+ return Err(CoreError::DispatchAdmission {+ method: AGENT_CHAT,+ source: *refusal,+ usage: report.usage.map(|spent| crate::complete::CompletionUsage {+ input_tokens: spent.input_tokens,+ output_tokens: spent.output_tokens,+ cached_tokens: spent.cached_tokens,+ reasoning_tokens: spent.reasoning_tokens,+ cost_usd: spent.cost_usd,+ }),+ });+ }}if outcome.is_err() && report.structured_failed {use crate::structured::{diff --git a/crates/openhuman-embed/src/turn_tests.rs b/crates/openhuman-embed/src/turn_tests.rsindex 21f496eb07..243e07e0c7 100644--- a/crates/openhuman-embed/src/turn_tests.rs+++ b/crates/openhuman-embed/src/turn_tests.rs@@ -89,14 +89,12 @@ fn typed_dispatch_refusal_precedes_structured_error_mapping_and_keeps_usage() {match mapped {CoreError::DispatchAdmission { source, usage, .. } => {- assert!(- CoreError::DispatchAdmission {- method: AGENT_CHAT,- source,- usage: None,- }- .is_expected_user_state()- );+ assert!(CoreError::DispatchAdmission {+ method: AGENT_CHAT,+ source,+ usage: None,+ }+ .is_expected_user_state());assert_eq!(source, refusal);let usage = usage.expect("the completed invalid response remains accounted");assert_eq!(usage.input_tokens, 13);