Skip to content

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

refactor(subagent_host): move worker thread and mirror modules under subagent host

Steven Enamakelf0b6d80423f1
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_host_impl.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_host_impl.rs
index 0a90a82e2a..332dcd94f1 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_host_impl.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_host_impl.rs
@@ -486,7 +486,7 @@ impl SpawnSubagentTool {
.and_then(|session| session.worker_thread_id.clone())
.or_else(|| {
parent_thread_id.as_ref().and_then(|parent_thread_id| {
- crate::threads::worker_thread::create_worker_thread(
+ crate::agent::subagent_host::create_worker_thread(
&dispatch,
parent.workspace_dir.clone(),
parent_thread_id,
@@ -501,7 +501,7 @@ impl SpawnSubagentTool {
(reusable.as_ref(), worker_thread_id.as_ref())
{
if session.worker_thread_id.as_deref() == Some(worker_thread_id.as_str()) {
- crate::threads::worker_thread::append_reuse_follow_up(
+ crate::agent::subagent_host::append_reuse_follow_up(
&dispatch,
parent.workspace_dir.clone(),
worker_thread_id,
diff --git a/crates/openhuman-core/src/agent/subagent_host/mod.rs b/crates/openhuman-core/src/agent/subagent_host/mod.rs
index 7dcbf8b2e1..ff0510132e 100644
--- a/crates/openhuman-core/src/agent/subagent_host/mod.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/mod.rs
@@ -73,3 +73,4 @@ pub use types::{
};
pub(crate) use ops::resolve_subagent_source;
+pub(crate) use ops::{append_reuse_follow_up, create_worker_thread};
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/graph.rs b/crates/openhuman-core/src/agent/subagent_host/ops/graph.rs
index 0c35a2b983..2149384736 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/graph.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/graph.rs
@@ -54,7 +54,7 @@ pub(super) use dispatch::AggregatedUsage;
#[cfg(test)]
use crate::progress::AgentProgress;
#[cfg(test)]
-use crate::threads::worker_mirror::{mirror_worker_thread, mirror_worker_thread_from_history};
+use super::{mirror_worker_thread, mirror_worker_thread_from_history};
#[cfg(test)]
use std::collections::HashSet;
#[cfg(test)]
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs b/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs
index 7d4a6c0d2b..f630475415 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs
@@ -17,7 +17,7 @@ use tinytools::{Tool, ToolSpec};
use tinytools_agent::dialect::TranscriptEntry;
use super::transcript::persist_subagent_transcript;
-use crate::threads::worker_mirror::mirror_worker_thread;
+use crate::agent::subagent_host::ops::mirror_worker_thread;
#[path = "dispatch_helpers.rs"]
mod helpers;
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/graph/transcript.rs b/crates/openhuman-core/src/agent/subagent_host/ops/graph/transcript.rs
index 87ed813698..2cd711f784 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/graph/transcript.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/graph/transcript.rs
@@ -9,7 +9,7 @@ use crate::agent::tinyagents::host::OpenHumanRunContext;
use tinyagents_session::transcript::{TranscriptLocator, TranscriptMessage, TranscriptTurn};
use super::dispatch::AggregatedUsage;
-use crate::threads::worker_mirror::mirror_worker_thread_from_history;
+use crate::agent::subagent_host::ops::mirror_worker_thread_from_history;
/// The history a failed sub-agent run persists, plus the unanswered steps as
/// text (#6281).
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/mod.rs b/crates/openhuman-core/src/agent/subagent_host/ops/mod.rs
index 5fbf4113bf..ea2a8789c3 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/mod.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/mod.rs
@@ -28,6 +28,17 @@ mod prompt;
mod provider;
mod runner;
mod runner_artifacts;
+mod worker_mirror;
+mod worker_thread;
+
+pub(crate) use worker_mirror::{mirror_worker_thread, mirror_worker_thread_from_history};
+pub(crate) use worker_thread::{
+ append_reuse_follow_up, append_worker_user_message, create_worker_thread,
+};
+
+#[cfg(test)]
+#[path = "worker_thread_tests.rs"]
+mod worker_thread_tests;
// The lifecycle adapter owns the public entry point. This is its host-only
// execution leaf after a neutral driver has prepared and admitted a request.
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/worker_thread.rs b/crates/openhuman-core/src/agent/subagent_host/ops/worker_thread.rs
index 374ed9671e..e9973b47dd 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/worker_thread.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/worker_thread.rs
@@ -107,10 +107,6 @@ pub(crate) fn append_worker_user_message(
.map(|_| ())
}
-#[cfg(test)]
-#[path = "worker_thread_tests.rs"]
-mod tests;
-
/// Appends a reused sub-agent's follow-up prompt to its worker thread. A
/// failure is logged and does not fail the spawn. `ids` is the parent thread
/// and the sub-agent session, for the log line.
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/worker_thread_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops/worker_thread_tests.rs
index 0387701d0a..7c5c0e7fe6 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/worker_thread_tests.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/worker_thread_tests.rs
@@ -1,4 +1,5 @@
use super::*;
+use crate::threads::store as conversations;
#[test]
fn creates_child_thread_linked_to_parent_and_seeds_prompt() {
diff --git a/crates/openhuman-core/src/threads/mod.rs b/crates/openhuman-core/src/threads/mod.rs
index cc12f91a54..d05b676264 100644
--- a/crates/openhuman-core/src/threads/mod.rs
+++ b/crates/openhuman-core/src/threads/mod.rs
@@ -14,8 +14,6 @@ pub mod store;
#[cfg(test)]
mod transcript_host_tests;
pub mod turn_state;
-pub(crate) mod worker_mirror;
-pub(crate) mod worker_thread;
pub use error::{ThreadsError, THREAD_NOT_FOUND_KIND};
pub use rpc_models::*;