Skip to content

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

feat(channels): add failure copy module for channel errors

Steven Enamakel147f5faf927f
diff --git a/crates/openhuman-core/src/channels/failure_copy.rs b/crates/openhuman-core/src/channels/failure_copy.rs
new file mode 100644
index 0000000000..8f819aa6dc
--- /dev/null
+++ b/crates/openhuman-core/src/channels/failure_copy.rs
@@ -0,0 +1,18 @@
+//! Shared localized copy for channel-host failures that are not inference
+//! failures (for example module setup, durable history, or reset errors).
+
+const GENERIC_FAILURE_KEY: &str = "chat_error.inference";
+const GENERIC_FAILURE_EN: &str = "Something went wrong. Please try again.";
+
+/// 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 {
+ match config {
+ Some(config) => config.render_native_channel_failure(
+ GENERIC_FAILURE_EN,
+ Some(GENERIC_FAILURE_KEY),
+ None,
+ ),
+ None => GENERIC_FAILURE_EN.to_owned(),
+ }
+}
diff --git a/crates/openhuman-core/src/channels/mod.rs b/crates/openhuman-core/src/channels/mod.rs
index b57bcb0849..7a1ed6af4c 100644
--- a/crates/openhuman-core/src/channels/mod.rs
+++ b/crates/openhuman-core/src/channels/mod.rs
@@ -22,6 +22,8 @@ pub(crate) use commands::{configured_providers, has_listener_configuration};
#[cfg(feature = "channels")]
pub(crate) mod context;
#[cfg(feature = "channels")]
+pub(crate) mod failure_copy;
+#[cfg(feature = "channels")]
pub mod controllers;
#[cfg(feature = "channels")]
pub mod host;
diff --git a/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs b/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs
index 56519aa757..eb95e35497 100644
--- a/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs
@@ -298,7 +298,7 @@ async fn relay_preflight_failure_uses_trusted_channel_locale_without_running_age
assert_eq!(agent_runs.load(std::sync::atomic::Ordering::SeqCst), 0);
assert_eq!(
replies,
- vec!["Este chat no está disponible temporalmente. Inténtalo de nuevo más tarde."]
+ vec!["Algo salió mal. Inténtalo de nuevo."]
);
assert!(!replies[0].contains("COMPONENT_DISABLED"));
}