Skip to content

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

refactor(orchestration): extract reuse follow-up append into worker_thread

Steven Enamakel08607637d991
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 17f5c48577..a133d85552 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
@@ -260,23 +260,15 @@ impl SpawnAsyncSubagentTool {
(reusable.as_ref(), worker_thread_id.as_ref())
{
if session.worker_thread_id.as_deref() == Some(worker_thread_id.as_str()) {
- if let Err(err) = super::worker_thread::append_worker_user_message(
+ super::worker_thread::append_reuse_follow_up(
&dispatch,
parent.workspace_dir.clone(),
worker_thread_id,
&definition.id,
&task_id,
&follow_up_prompt,
- ) {
- log::warn!(
- "[subagent_reuse] worker follow-up append failed parent_thread_id={} subagent_session_id={} worker_thread_id={} task_id={} error={}",
- parent_thread_id.as_deref().unwrap_or("none"),
- session.subagent_session_id,
- worker_thread_id,
- task_id,
- err
- );
- }
+ (parent_thread_id.as_deref(), &session.subagent_session_id),
+ );
}
}
let durable_session = match subagent_sessions::upsert_running(
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/worker_thread.rs b/crates/openhuman-core/src/agent/orchestration/tools/worker_thread.rs
index aa4c70d2c5..8771858bff 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/worker_thread.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/worker_thread.rs
@@ -111,3 +111,34 @@ pub(crate) fn append_worker_user_message(
#[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.
+pub(crate) fn append_reuse_follow_up(
+ ctx: &DispatchCtx,
+ workspace_dir: PathBuf,
+ worker_thread_id: &str,
+ agent_id: &str,
+ task_id: &str,
+ prompt: &str,
+ ids: (Option<&str>, &str),
+) {
+ if let Err(err) = append_worker_user_message(
+ ctx,
+ workspace_dir,
+ worker_thread_id,
+ agent_id,
+ task_id,
+ prompt,
+ ) {
+ log::warn!(
+ "[subagent_reuse] worker follow-up append failed parent_thread_id={} subagent_session_id={} worker_thread_id={} task_id={} error={}",
+ ids.0.unwrap_or("none"),
+ ids.1,
+ worker_thread_id,
+ task_id,
+ err
+ );
+ }
+}