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(channels): improve test harness workspace isolation
Steven Enamakel8a68dbe51ae6
diff --git a/crates/openhuman-core/src/channels/runtime/test_support.rs b/crates/openhuman-core/src/channels/runtime/test_support.rsindex f327128d91..93e3f7725c 100644--- a/crates/openhuman-core/src/channels/runtime/test_support.rs+++ b/crates/openhuman-core/src/channels/runtime/test_support.rs@@ -35,7 +35,7 @@ pub struct DispatchHarnessOptions {pub handler_error: Option<String>,pub handler_delay_ms: u64,pub timeout_secs: u64,- /// Workspace the runtime context reports; `None` falls back to the OS temp dir.+ /// Workspace the runtime context reports; `None` uses an isolated temporary workspace.////// `pub`, like every other field here, and it has to be: integration tests/// under `tests/` are a separate crate, and a struct-update expression@@ -300,6 +300,8 @@ pub async fn run_dispatch_harness(options: DispatchHarnessOptions) -> DispatchHa// The real agent handler and global registries are process-wide. Serialize// the whole harness run so concurrent tests cannot replace them mid-turn.let _agent_handler_guard = crate::agent::bus::use_real_agent_handler().await;+ let _storage = crate::channels::module_fixture::install_memory_storage();+ crate::channels::module_fixture::client().await;crate::core::bus::init().await.expect("bus init");let mut event_rx = crate::core::bus::BUS@@ -341,10 +343,13 @@ pub async fn run_dispatch_harness(options: DispatchHarnessOptions) -> DispatchHa.clone().into_inner().unwrap_or_else(|| ChannelSystemPrompt::fixed("system prompt"));- let harness_workspace_dir = options- .workspace_dir- .clone()- .unwrap_or_else(std::env::temp_dir);+ let (harness_workspace_dir, _workspace_guard) = match options.workspace_dir.clone() {+ Some(workspace) => (workspace, None),+ None => {+ let workspace = tempfile::tempdir().expect("temporary dispatch harness workspace");+ (workspace.path().to_path_buf(), Some(workspace))+ }+ };let ctx = Arc::new(ChannelRuntimeContext {relay_thread: None,channels_by_name: Arc::new(channels_by_name),diff --git a/crates/openhuman-core/src/channels/tests/host_pipeline.rs b/crates/openhuman-core/src/channels/tests/host_pipeline.rsindex 00aced0e4e..b3ff235894 100644--- a/crates/openhuman-core/src/channels/tests/host_pipeline.rs+++ b/crates/openhuman-core/src/channels/tests/host_pipeline.rs@@ -114,6 +114,29 @@ async fn host_dispatch_preserves_thread_reply_and_reaction_targets() {assert!(reaction.model_calls[0].text.contains("hello"));}+#[tokio::test]+async fn dispatch_harness_default_workspace_does_not_reuse_prior_transcript() {+ let first = run_dispatch_harness(DispatchHarnessOptions {+ content: "first isolated harness turn".into(),+ ..Default::default()+ })+ .await;+ assert_eq!(first.model_calls.len(), 1);++ let second = run_dispatch_harness(DispatchHarnessOptions {+ content: "second isolated harness turn".into(),+ ..Default::default()+ })+ .await;+ assert_eq!(second.model_calls.len(), 1);+ assert!(second.model_calls[0]+ .text+ .contains("second isolated harness turn"));+ assert!(!second.model_calls[0]+ .text+ .contains("first isolated harness turn"));+}+#[tokio::test]async fn discord_host_pipeline_dispatches_reply_with_thread_context() {let observation = run_dispatch_harness(DispatchHarnessOptions {@@ -135,6 +158,8 @@ async fn discord_host_pipeline_dispatches_reply_with_thread_context() {#[tokio::test]async fn discord_host_pipeline_keeps_thread_histories_separate() {let _bus_guard = use_real_agent_handler().await;+ let _storage = crate::channels::module_fixture::install_memory_storage();+ crate::channels::module_fixture::client().await;let workspace = tempfile::tempdir().expect("temporary Discord workspace");let channel_state = Arc::new(crate::channels::runtime::TestChannel::new("discord"));let channel = Arc::new(ChannelHandle::Test(Arc::clone(&channel_state)));