Skip to content

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

refactor(channels): improve workspace handling in test harness

Steven Enamakel4290e5147586
diff --git a/crates/openhuman-core/src/channels/runtime/test_support.rs b/crates/openhuman-core/src/channels/runtime/test_support.rs
index 25532b8e55..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
@@ -343,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.rs
index b3ff235894..00332cbbc4 100644
--- a/crates/openhuman-core/src/channels/tests/host_pipeline.rs
+++ b/crates/openhuman-core/src/channels/tests/host_pipeline.rs
@@ -122,6 +122,11 @@ async fn dispatch_harness_default_workspace_does_not_reuse_prior_transcript() {
})
.await;
assert_eq!(first.model_calls.len(), 1);
+ assert_eq!(
+ first.sends.len(),
+ 1,
+ "the first harness turn replies successfully"
+ );
let second = run_dispatch_harness(DispatchHarnessOptions {
content: "second isolated harness turn".into(),