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
test(web_chat): add test hooks for chat task errors
Steven Enamakel2154a387b515
diff --git a/crates/openhuman-core/src/channels/bus/subscriber_tests.rs b/crates/openhuman-core/src/channels/bus/subscriber_tests.rsindex 6a2af135dc..82bbd39e15 100644--- a/crates/openhuman-core/src/channels/bus/subscriber_tests.rs+++ b/crates/openhuman-core/src/channels/bus/subscriber_tests.rs@@ -39,6 +39,7 @@ async fn backend_channel_wait_does_not_cut_off_a_live_turn_after_180_seconds() {succeed_in: Some(workspace.path().to_path_buf()),};crate::web_chat::set_test_run_chat_task_block(Some(block.clone())).await;+ crate::web_chat::ops::set_last_run_chat_task_error_for_test(None).await;let ctx = DispatchCtx::ambient();let client_id = "channel-timeout-client";@@ -65,8 +66,11 @@ async fn backend_channel_wait_does_not_cut_off_a_live_turn_after_180_seconds() {match event_rx.try_recv() {Ok(event) if event.context().request_id == request_id => match event.wire_event() {WebChannelEvent::ChatError { message, .. } => {+ let detail = crate::web_chat::last_run_chat_task_error_for_test()+ .await+ .unwrap_or_else(|| "runner did not expose an internal failure".into());return Err(format!(- "shared runner failed before entering controlled turn: {}",+ "shared runner failed before entering controlled turn: {detail}; classified message: {}",message.as_deref().unwrap_or("no error message")));}diff --git a/crates/openhuman-core/src/web_chat/mod.rs b/crates/openhuman-core/src/web_chat/mod.rsindex 8d570913a5..b521f2ca9b 100644--- a/crates/openhuman-core/src/web_chat/mod.rs+++ b/crates/openhuman-core/src/web_chat/mod.rs@@ -86,6 +86,8 @@ pub(crate) use ops::lock_thread_sessions_for_test;#[cfg(any(test, debug_assertions))]pub use ops::parallel_in_flight_entries_for_test;#[cfg(test)]+pub(crate) use ops::last_run_chat_task_error_for_test;+#[cfg(test)]pub(crate) use ops::track_parallel_turn_for_test;pub use ops::{cancel_all_turns, cancel_chat_scoped, cancel_should_target, channel_web_cancel,diff --git a/crates/openhuman-core/src/web_chat/ops.rs b/crates/openhuman-core/src/web_chat/ops.rsindex 8da87704e4..633a997161 100644--- a/crates/openhuman-core/src/web_chat/ops.rs+++ b/crates/openhuman-core/src/web_chat/ops.rs@@ -50,3 +50,7 @@ pub use test_hooks::RUN_CHAT_TASK_TEST_LOCK;pub(super) use test_hooks::{run_test_hooks, test_hooks_active, TEST_PARK_AFTER_RUN};#[cfg(any(test, debug_assertions))]pub use test_hooks::{set_test_park_after_run, set_test_run_chat_task_block, TestRunChatTaskBlock};+#[cfg(test)]+pub(crate) use test_hooks::{+ last_run_chat_task_error_for_test, set_last_run_chat_task_error_for_test,+};diff --git a/crates/openhuman-core/src/web_chat/ops/test_hooks.rs b/crates/openhuman-core/src/web_chat/ops/test_hooks.rsindex bf6aeed58c..427e558ee5 100644--- a/crates/openhuman-core/src/web_chat/ops/test_hooks.rs+++ b/crates/openhuman-core/src/web_chat/ops/test_hooks.rs@@ -36,6 +36,20 @@ pub struct TestRunChatTaskBlock {pub(crate) static TEST_RUN_CHAT_TASK_BLOCK: Lazy<Mutex<Option<TestRunChatTaskBlock>>> =Lazy::new(|| Mutex::new(None));+#[cfg(test)]+pub(crate) static TEST_LAST_RUN_CHAT_TASK_ERROR: Lazy<Mutex<Option<String>>> =+ Lazy::new(|| Mutex::new(None));++#[cfg(test)]+pub(crate) async fn set_last_run_chat_task_error_for_test(error: Option<&str>) {+ *TEST_LAST_RUN_CHAT_TASK_ERROR.lock().await = error.map(str::to_owned);+}++#[cfg(test)]+pub(crate) async fn last_run_chat_task_error_for_test() -> Option<String> {+ TEST_LAST_RUN_CHAT_TASK_ERROR.lock().await.clone()+}+/// Process-wide lock serializing every test that drives the global/// `run_chat_task` test hooks (`set_test_run_chat_task_block`,/// `set_test_forced_run_chat_task_error`) or the `OPENHUMAN_WEB_TURN_TIMEOUT_SECS`diff --git a/crates/openhuman-core/src/web_chat/turn_events.rs b/crates/openhuman-core/src/web_chat/turn_events.rsindex 9d5a44c447..0491093d0e 100644--- a/crates/openhuman-core/src/web_chat/turn_events.rs+++ b/crates/openhuman-core/src/web_chat/turn_events.rs@@ -279,6 +279,8 @@ impl WebEvents {}async fn failed(&self, request: &TurnRequest<QueuedPayload>, surface: &Surface, error: &str) {+ #[cfg(test)]+ super::ops::set_last_run_chat_task_error_for_test(Some(error)).await;let parallel =request.disposition == tinyagents_harness::turn_runner::QueueDisposition::Parallel;let raw = host_error(error, Some(request));