Skip to content

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

refactor(orchestration): move completion target test helpers into a test module

Steven Enamakelc196724055b5
diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions.rs b/crates/openhuman-core/src/agent/orchestration/background_completions.rs
index abd814061c..1f69d261b1 100644
--- a/crates/openhuman-core/src/agent/orchestration/background_completions.rs
+++ b/crates/openhuman-core/src/agent/orchestration/background_completions.rs
@@ -46,7 +46,7 @@ use super::completion_target::{awaiting_input_record_id, awaiting_input_record_p
pub(crate) use super::completion_target::{claim_recovery, forget_recovery};
#[cfg(test)]
pub(crate) use super::completion_target::{
- forget_workspace_for_test, install_store_for_test, TestWorkspace,
+ forget_workspace_for_test, install_store_for_test, tests::TestWorkspace,
};
/// How long a settled record (delivered / gave up / tombstoned) is kept before
diff --git a/crates/openhuman-core/src/agent/orchestration/completion_target.rs b/crates/openhuman-core/src/agent/orchestration/completion_target.rs
index e64390a4b2..25fc6fc699 100644
--- a/crates/openhuman-core/src/agent/orchestration/completion_target.rs
+++ b/crates/openhuman-core/src/agent/orchestration/completion_target.rs
@@ -6,9 +6,6 @@
use std::path::Path;
use std::path::PathBuf;
-use std::sync::Arc;
-#[cfg(test)]
-use tinyagents_tasks::CompletionStore;
use super::background_completions::state;
#[cfg(test)]
@@ -16,6 +13,10 @@ use super::background_completions::{new_router, Entry};
use super::background_completions::{record_awaiting_input, record_completion, record_failure};
+#[cfg(test)]
+#[path = "completion_target_tests.rs"]
+pub(crate) mod tests;
+
/// Completion-router key prefix for one task's awaiting-input notices.
pub(super) fn awaiting_input_record_prefix(task_id: &str) -> String {
let encoded_task_id: String = task_id
diff --git a/crates/openhuman-core/src/agent/orchestration/completion_target_tests.rs b/crates/openhuman-core/src/agent/orchestration/completion_target_tests.rs
index 1a8f621219..64ad90dcec 100644
--- a/crates/openhuman-core/src/agent/orchestration/completion_target_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/completion_target_tests.rs
@@ -1,14 +1,13 @@
use std::path::Path;
use std::sync::Arc;
+use super::super::background_completions::{new_router, state, Entry};
use tinyagents_tasks::CompletionStore;
/// A temporary workspace that forgets its router when dropped, so the
/// process-wide registry does not accumulate entries for deleted directories.
-#[cfg(test)]
pub(crate) struct TestWorkspace(tempfile::TempDir);
-#[cfg(test)]
impl TestWorkspace {
pub(crate) fn new() -> Self {
Self(tempfile::tempdir().expect("tempdir"))
@@ -19,7 +18,6 @@ impl TestWorkspace {
}
}
-#[cfg(test)]
impl Drop for TestWorkspace {
fn drop(&mut self) {
forget_workspace_for_test(self.0.path());
@@ -28,7 +26,6 @@ impl Drop for TestWorkspace {
/// Register `store` as `workspace_dir`'s completion store, so a test can inject
/// one that fails.
-#[cfg(test)]
pub(crate) fn install_store_for_test(workspace_dir: &Path, store: Arc<dyn CompletionStore>) {
let entry = Arc::new(Entry {
router: Arc::new(new_router(store.clone())),
@@ -40,7 +37,6 @@ pub(crate) fn install_store_for_test(workspace_dir: &Path, store: Arc<dyn Comple
/// Forget everything this process knows about `workspace_dir`, as a restart
/// would: the router (and its open log handle) and every thread/session mapping
/// that points at it. The on-disk log is untouched.
-#[cfg(test)]
pub(crate) fn forget_workspace_for_test(workspace_dir: &Path) {
let mut st = state();
st.routers.remove(workspace_dir);
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/delegate_graph.rs b/crates/openhuman-core/src/agent/orchestration/tools/delegate_graph.rs
index 4e95969c44..dc85844b49 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/delegate_graph.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/delegate_graph.rs
@@ -206,7 +206,7 @@ impl DelegateGraphTool {
};
let agent_id = match args.get("agent_id").and_then(|v| v.as_str()) {
Some(s) if !s.trim().is_empty() => s.trim().to_string(),
- _ => return Ok(ToolResult::error("delegate: `agent_id` is required.")),
+ _ => return Ok(ToolResult::error("delegate_graph: `agent_id` is required.")),
};
let task = match args.get("task").and_then(|v| v.as_str()) {
Some(s) if !s.trim().is_empty() => s.to_string(),