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(embed): handle missing chat reply text and error messages
Steven Enamakel0f6b801397ae
diff --git a/crates/openhuman-embed/src/profiles/handle.rs b/crates/openhuman-embed/src/profiles/handle.rsindex 1883216ba8..36a7a4f715 100644--- a/crates/openhuman-embed/src/profiles/handle.rs+++ b/crates/openhuman-embed/src/profiles/handle.rs@@ -245,7 +245,7 @@ impl ProfileHandle {return Ok(ChatReply {thread_id: thread_id.to_string(),request_id,- text: full_response.clone(),+ text: chat_reply_text(full_response.clone()),});}WebChannelEvent::ChatError {@@ -259,7 +259,7 @@ impl ProfileHandle {error_type);return Err(ProfileError::Turn {- message: message.clone(),+ message: chat_failure_message(message.clone()),error_type: error_type.clone(),});}@@ -353,3 +353,15 @@ impl ProfileHandle {Ok(())}}++fn chat_reply_text(full_response: Option<String>) -> String {+ full_response.unwrap_or_default()+}++fn chat_failure_message(message: Option<String>) -> String {+ message.unwrap_or_else(|| "The turn failed without an error message.".to_string())+}++#[cfg(test)]+#[path = "handle_tests.rs"]+mod tests;diff --git a/crates/openhuman-embed/src/profiles/handle_tests.rs b/crates/openhuman-embed/src/profiles/handle_tests.rsnew file mode 100644index 0000000000..e3e9710bba--- /dev/null+++ b/crates/openhuman-embed/src/profiles/handle_tests.rs@@ -0,0 +1,27 @@+use super::*;++#[test]+fn a_done_event_without_legacy_response_text_returns_an_empty_reply() {+ assert_eq!(chat_reply_text(None), "");+}++#[test]+fn a_done_event_keeps_its_response_text() {+ assert_eq!(chat_reply_text(Some("answer".into())), "answer");+}++#[test]+fn an_error_event_without_legacy_message_gets_safe_user_facing_copy() {+ assert_eq!(+ chat_failure_message(None),+ "The turn failed without an error message."+ );+}++#[test]+fn an_error_event_keeps_its_message() {+ assert_eq!(+ chat_failure_message(Some("provider failed".into())),+ "provider failed"+ );+}