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(channels): route channel failures through shared copy
Steven Enamakelb84e62e980ce
diff --git a/crates/openhuman-core/src/agent/host_agents.rs b/crates/openhuman-core/src/agent/host_agents.rsindex 71f4e8dcb4..75a3dc9ded 100644--- a/crates/openhuman-core/src/agent/host_agents.rs+++ b/crates/openhuman-core/src/agent/host_agents.rs@@ -119,7 +119,10 @@ impl HostAgent {.await.map_err(anyhow::Error::msg)})- .await?;+ .await+ .map_err(|_| {+ anyhow::anyhow!(crate::channels::failure_copy::LEGACY_HISTORY_UNAVAILABLE)+ })?;}self.scope(crate::agent::turn_host::AgentTurnHost::run(&mut session,diff --git a/crates/openhuman-core/src/channels/failure_copy.rs b/crates/openhuman-core/src/channels/failure_copy.rsindex 8f819aa6dc..95f53a7227 100644--- a/crates/openhuman-core/src/channels/failure_copy.rs+++ b/crates/openhuman-core/src/channels/failure_copy.rs@@ -4,6 +4,11 @@const GENERIC_FAILURE_KEY: &str = "chat_error.inference";const GENERIC_FAILURE_EN: &str = "Something went wrong. Please try again.";+/// Internal sentinel used only between the channel host and its runner. It+/// deliberately carries no storage/provider details into user-facing copy.+pub(crate) const LEGACY_HISTORY_UNAVAILABLE: &str =+ "openhuman-channel-history-unavailable";+/// Render a non-inference channel failure without exposing implementation/// details or classifying it as a provider failure.pub(crate) fn generic_failure(config: Option<&crate::config::Config>) -> String {diff --git a/crates/openhuman-core/src/channels/providers/relay/ops.rs b/crates/openhuman-core/src/channels/providers/relay/ops.rsindex 76ab32ac0e..9ac1fb6223 100644--- a/crates/openhuman-core/src/channels/providers/relay/ops.rs+++ b/crates/openhuman-core/src/channels/providers/relay/ops.rs@@ -179,11 +179,10 @@ pub(crate) async fn run_relay_turn(Ok(limits) => limits,Err(error) => {tracing::warn!("relayed channel runtime limits unavailable: {error}");- let reply =- "⚠️ This chat's assistant is not available right now. Please try again later.";+ let reply = crate::channels::failure_copy::generic_failure(Some(&config));let _ = tinychannels_runtime::Channel::send(channel.as_ref(),- &crate::channels::SendMessage::new(reply, ¶ms.chat_id),+ &crate::channels::SendMessage::new(&reply, ¶ms.chat_id),).await;record(@@ -217,10 +216,10 @@ pub(crate) async fn run_relay_turn("[channels::relay] could not build the turn");let reply =- "⚠️ This chat's assistant is not available right now. Please try again later.";+ crate::channels::failure_copy::generic_failure(Some(&config));let _ = tinychannels_runtime::Channel::send(channel.as_ref(),- &crate::channels::SendMessage::new(reply, ¶ms.chat_id),+ &crate::channels::SendMessage::new(&reply, ¶ms.chat_id),).await;record(@@ -268,6 +267,20 @@ pub(crate) async fn run_relay_turn(Ok(prepared) => prepared,Err(error) => {tracing::warn!("relayed channel preparation failed: {error}");+ let reply = crate::channels::failure_copy::generic_failure(Some(&config));+ let _ = tinychannels_runtime::Channel::send(+ channel.as_ref(),+ &crate::channels::SendMessage::new(&reply, ¶ms.chat_id),+ )+ .await;+ record(+ &dispatch_ctx,+ &workspace_dir,+ ¶ms,+ &thread_id,+ &channel.sent(),+ )+ .await;return channel.sent();}};diff --git a/crates/openhuman-core/src/channels/routes.rs b/crates/openhuman-core/src/channels/routes.rsindex 65169d5ca8..91b0cb1310 100644--- a/crates/openhuman-core/src/channels/routes.rs+++ b/crates/openhuman-core/src/channels/routes.rs@@ -240,9 +240,10 @@ where}Err(_) => {if let Some(channel) = target_channel {+ let reply = crate::channels::failure_copy::generic_failure(ctx.config.as_deref());let _ = channel.send_with_outbound_intent(- &SendMessage::new("Channel module unavailable.", &msg.reply_target)+ &SendMessage::new(&reply, &msg.reply_target).in_thread(msg.thread_ts.clone()),).await;@@ -250,31 +251,31 @@ wherereturn true;}};- if let Some(route) = next_route {- set_route_selection(- ctx,- sender_key,- ChannelRouteSelection {- provider: route.provider,- model: route.model,- },- );- }if clear_history && reset_history().await.is_err() {tracing::warn!("channel durable history reset failed");if let Some(channel) = target_channel {- let copy = crate::web_chat::classify_inference_error(- "OpenHuman session persistence failed while resetting this conversation",- );+ let copy = crate::channels::failure_copy::generic_failure(ctx.config.as_deref());let _ = channel.send_with_outbound_intent(- &SendMessage::new(copy.message, &msg.reply_target)+ &SendMessage::new(©, &msg.reply_target).in_thread(msg.thread_ts.clone()),).await;}return true;}+ // Apply a route change only after its requested durable reset has+ // succeeded, so a failed reset cannot partially alter command state.+ if let Some(route) = next_route {+ set_route_selection(+ ctx,+ sender_key,+ ChannelRouteSelection {+ provider: route.provider,+ model: route.model,+ },+ );+ }let Some(reply) = reply else {return false;};diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/native_runner.rs b/crates/openhuman-core/src/channels/runtime/dispatch/native_runner.rsindex 3ec17ea840..432cb3a3f4 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/native_runner.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/native_runner.rs@@ -451,11 +451,25 @@ struct NativeFailures;impl FailureClassifier for NativeFailures {fn classify(&self, error: &str) -> (String, String) {+ if error == crate::channels::failure_copy::LEGACY_HISTORY_UNAVAILABLE {+ return (+ "channel_history_unavailable".to_owned(),+ "Something went wrong. Please try again.".to_owned(),+ );+ }let classified = crate::web_chat::classify_inference_error(error);(classified.error_type.to_owned(), classified.message)}fn classify_failure(&self, error: &str) -> FailureClassification {+ if error == crate::channels::failure_copy::LEGACY_HISTORY_UNAVAILABLE {+ return FailureClassification {+ class: "channel_history_unavailable".to_owned(),+ message: "Something went wrong. Please try again.".to_owned(),+ copy_key: Some("chat_error.inference".to_owned()),+ copy_params: None,+ };+ }let classified = crate::web_chat::classify_inference_error(error);FailureClassification {class: classified.error_type.to_owned(),