Skip to content

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

refactor(threads): move run mode and worker thread modules under threads

Steven Enamakel9a4de7022149
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs
index e79698f40c..bbd41745ce 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs
@@ -245,7 +245,7 @@ impl SpawnAsyncSubagentTool {
.and_then(|session| session.worker_thread_id.clone())
.or_else(|| {
parent_thread_id.as_ref().and_then(|parent_thread_id| {
- super::worker_thread::create_worker_thread(
+ crate::threads::worker_thread::create_worker_thread(
&dispatch,
parent.workspace_dir.clone(),
parent_thread_id,
@@ -260,7 +260,7 @@ impl SpawnAsyncSubagentTool {
(reusable.as_ref(), worker_thread_id.as_ref())
{
if session.worker_thread_id.as_deref() == Some(worker_thread_id.as_str()) {
- super::worker_thread::append_reuse_follow_up(
+ crate::threads::worker_thread::append_reuse_follow_up(
&dispatch,
parent.workspace_dir.clone(),
worker_thread_id,
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs
index c062a99894..2c951c4463 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs
@@ -256,7 +256,7 @@ impl SpawnSubagentTool {
let worker_thread_id = run_context.parent.as_ref().and_then(|p| {
let parent_thread_id = parent_thread_id.as_ref()?;
let title: String = prompt.chars().take(60).collect();
- super::worker_thread::create_worker_thread(
+ crate::threads::worker_thread::create_worker_thread(
&dispatch,
p.workspace_dir.clone(),
parent_thread_id,
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
index f3cc24aa05..e527fcbca8 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
@@ -524,7 +524,7 @@ async fn drive_turn(
hosted_security_gate,
pause_at_cap,
run_mode: run_context.thread_id.as_deref().map(|thread_id| {
- crate::agent::tinyagents::run_mode::handle_for_thread(
+ crate::threads::run_mode::handle_for_thread(
&run_context.dispatch_ctx(),
thread_id,
)
diff --git a/crates/openhuman-core/src/agent/tools/plan_exit.rs b/crates/openhuman-core/src/agent/tools/plan_exit.rs
index b2be5311dd..8d98d04c3f 100644
--- a/crates/openhuman-core/src/agent/tools/plan_exit.rs
+++ b/crates/openhuman-core/src/agent/tools/plan_exit.rs
@@ -124,7 +124,7 @@ impl PlanExitTool {
thread_id = %thread_id,
"[tool][plan_exit] flipping thread run mode to build"
);
- crate::agent::tinyagents::run_mode::set_mode(
+ crate::threads::run_mode::set_mode(
&crate::agent::tinyagents::host::run_context::dispatch_ctx_for_tool(context),
thread_id,
tinyagents_harness::middleware::RunMode::Build,
diff --git a/crates/openhuman-core/src/agent/tools/plan_exit_tests.rs b/crates/openhuman-core/src/agent/tools/plan_exit_tests.rs
index 9dddfcfb9d..0802e4dfb7 100644
--- a/crates/openhuman-core/src/agent/tools/plan_exit_tests.rs
+++ b/crates/openhuman-core/src/agent/tools/plan_exit_tests.rs
@@ -16,7 +16,7 @@ impl ToolRunContext for ThreadContext {
#[tokio::test]
async fn plan_exit_does_not_flip_while_a_review_is_parked() {
let thread_id = "plan-exit-parked-thread";
- crate::agent::tinyagents::run_mode::set_mode(
+ crate::threads::run_mode::set_mode(
&crate::core::runtime::DispatchCtx::ambient(),
thread_id,
tinyagents_harness::middleware::RunMode::Plan,
@@ -51,7 +51,7 @@ async fn plan_exit_does_not_flip_while_a_review_is_parked() {
.unwrap();
assert!(!result.is_error);
assert_eq!(
- crate::agent::tinyagents::run_mode::get_mode(
+ crate::threads::run_mode::get_mode(
&crate::core::runtime::DispatchCtx::ambient(),
thread_id
),
@@ -84,7 +84,7 @@ async fn plan_exit_does_not_flip_while_a_review_is_parked() {
.unwrap();
assert!(!result.is_error);
assert_eq!(
- crate::agent::tinyagents::run_mode::get_mode(
+ crate::threads::run_mode::get_mode(
&crate::core::runtime::DispatchCtx::ambient(),
thread_id
),
diff --git a/crates/openhuman-core/src/core/all.rs b/crates/openhuman-core/src/core/all.rs
index 598f9a6d6d..3c42833e0b 100644
--- a/crates/openhuman-core/src/core/all.rs
+++ b/crates/openhuman-core/src/core/all.rs
@@ -450,7 +450,7 @@ fn build_registered_controllers() -> Vec<GroupedController> {
push(
&mut controllers,
DomainGroup::Agent,
- crate::agent::tinyagents::run_mode::all_registered_controllers(),
+ crate::threads::run_mode::all_registered_controllers(),
);
// Agent-generated artifact storage, retrieval, and lifecycle management
push(
diff --git a/crates/openhuman-core/src/core/events.rs b/crates/openhuman-core/src/core/events.rs
index cc7626f200..9797501f1c 100644
--- a/crates/openhuman-core/src/core/events.rs
+++ b/crates/openhuman-core/src/core/events.rs
@@ -1323,11 +1323,11 @@ pub enum DomainEvent {
/// A thread's [`tinyagents_harness::middleware::RunMode`] (Plan vs Build)
/// changed, via `agent.set_run_mode` or the `plan_exit` tool. Bridged to
/// the `run_mode_changed` web-channel socket event by
- /// `crate::agent::tinyagents::run_mode::set_mode`'s caller.
+ /// `crate::threads::run_mode::set_mode`'s caller.
ThreadRunModeChanged {
thread_id: String,
/// `"plan"` or `"build"` — see
- /// `crate::agent::tinyagents::run_mode::mode_label`.
+ /// `crate::threads::run_mode::mode_label`.
mode: String,
},
}
diff --git a/crates/openhuman-core/src/plan_review/tool.rs b/crates/openhuman-core/src/plan_review/tool.rs
index fe0edfcf21..d9d0794f57 100644
--- a/crates/openhuman-core/src/plan_review/tool.rs
+++ b/crates/openhuman-core/src/plan_review/tool.rs
@@ -150,7 +150,7 @@ impl RequestPlanReviewTool {
let mode = thread_id
.as_deref()
.map(|thread_id| {
- crate::agent::tinyagents::run_mode::get_mode(
+ crate::threads::run_mode::get_mode(
&crate::agent::tinyagents::host::run_context::dispatch_ctx_for_tool(context),
thread_id,
)
diff --git a/crates/openhuman-core/src/plan_review/tool_tests.rs b/crates/openhuman-core/src/plan_review/tool_tests.rs
index 82e9c621f7..552ffe883e 100644
--- a/crates/openhuman-core/src/plan_review/tool_tests.rs
+++ b/crates/openhuman-core/src/plan_review/tool_tests.rs
@@ -30,7 +30,7 @@ async fn interactive_turn_parks_until_resolved() {
// The tool is inert (no-ops rather than parks) outside Plan mode — see
// `plan_mode_is_inert_outside_plan_mode` below — so this thread must be
// in Plan mode for the park to actually happen.
- crate::agent::tinyagents::run_mode::set_mode(
+ crate::threads::run_mode::set_mode(
&crate::core::runtime::DispatchCtx::ambient(),
"t-int",
tinyagents_harness::middleware::RunMode::Plan,
diff --git a/crates/openhuman-core/src/tools/impl/threads/spawn_worker_thread.rs b/crates/openhuman-core/src/tools/impl/threads/spawn_worker_thread.rs
index a8be93f2f8..e33a1b22fb 100644
--- a/crates/openhuman-core/src/tools/impl/threads/spawn_worker_thread.rs
+++ b/crates/openhuman-core/src/tools/impl/threads/spawn_worker_thread.rs
@@ -291,7 +291,7 @@ impl SpawnWorkerThreadTool {
// ── Create Worker Thread ───────────────────────────────────────
// Shared with `spawn_subagent` so both delegation paths persist an
// identical, reopenable sub-thread seeded with the prompt.
- let worker_thread_id = super::worker_thread::create_worker_thread(
+ let worker_thread_id = crate::threads::worker_thread::create_worker_thread(
&dispatch,
parent.workspace_dir.clone(),
&current_thread_id,
diff --git a/crates/openhuman-core/src/web_chat/ops/channel_ops.rs b/crates/openhuman-core/src/web_chat/ops/channel_ops.rs
index 491e79e46f..e09f7a45f0 100644
--- a/crates/openhuman-core/src/web_chat/ops/channel_ops.rs
+++ b/crates/openhuman-core/src/web_chat/ops/channel_ops.rs
@@ -267,9 +267,9 @@ pub async fn channel_web_chat(
// `agent.set_run_mode` RPC. Unrecognized values are logged and ignored
// — a stale/typo'd client build must not fail the whole turn.
if let Some(run_mode) = run_mode.as_deref() {
- match crate::agent::tinyagents::run_mode::parse_mode_label(run_mode) {
+ match crate::threads::run_mode::parse_mode_label(run_mode) {
Some(mode) => {
- crate::agent::tinyagents::run_mode::set_mode(ctx, thread_id, mode);
+ crate::threads::run_mode::set_mode(ctx, thread_id, mode);
}
None => log::warn!(
"[web_chat] channel_web_chat thread_id={thread_id} ignoring unrecognized run_mode={run_mode}"