Skip to content

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

refactor(orchestration): consolidate background delivery scheduling

Steven Enamakel636ece1df1f2
diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions.rs b/crates/openhuman-core/src/agent/orchestration/background_completions.rs
index 7f92e7a838..d7714a5f7d 100644
--- a/crates/openhuman-core/src/agent/orchestration/background_completions.rs
+++ b/crates/openhuman-core/src/agent/orchestration/background_completions.rs
@@ -110,7 +110,8 @@ fn entry_for(workspace_dir: &Path) -> Arc<Entry> {
router: Arc::new(router),
store,
});
- st.routers.insert(workspace_dir.to_path_buf(), entry.clone());
+ st.routers
+ .insert(workspace_dir.to_path_buf(), entry.clone());
log::debug!(
"[background_completions] opened router workspace_dir={}",
workspace_dir.display()
@@ -341,7 +342,9 @@ pub(crate) fn discard_for_thread(thread_id: &str) -> usize {
let mut st = state();
st.thread_workspaces.remove(thread_id);
st.stopped_threads.remove(thread_id);
- log::debug!("[background_completions] discard_for_thread thread_id={thread_id} removed={removed}");
+ log::debug!(
+ "[background_completions] discard_for_thread thread_id={thread_id} removed={removed}"
+ );
removed
}
@@ -380,9 +383,7 @@ pub(crate) fn finish_stop_for_thread(thread_id: &str, task_ids: &[String]) {
};
for task_id in task_ids {
if let Err(error) = router.tombstone(task_id) {
- log::warn!(
- "[background_completions] tombstone failed task_id={task_id} error={error}"
- );
+ log::warn!("[background_completions] tombstone failed task_id={task_id} error={error}");
}
}
}
diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs b/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs
index c2220c58ba..dee7deb005 100644
--- a/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs
@@ -49,7 +49,10 @@ fn record_is_thread_scoped_and_batches_in_completion_order() {
let claimed = router.claim_pending("thread-A", usize::MAX).unwrap();
assert_eq!(claimed.len(), 2, "everything ready is claimed as one batch");
assert_eq!(claimed[0].result.text, "eiffel");
- assert!(router.claim_pending("thread-A", usize::MAX).unwrap().is_empty());
+ assert!(router
+ .claim_pending("thread-A", usize::MAX)
+ .unwrap()
+ .is_empty());
}
#[test]
@@ -81,7 +84,10 @@ fn the_session_is_mapped_to_its_thread_for_the_idle_gate() {
let _guard = test_guard();
let ws = workspace();
record(ws.path(), "sess-map", "sub-1", "x", Some("thread-map"));
- assert_eq!(thread_for_session("sess-map").as_deref(), Some("thread-map"));
+ assert_eq!(
+ thread_for_session("sess-map").as_deref(),
+ Some("thread-map")
+ );
// A web-channel session id carries its thread in the JSON body.
let web = r#"{"client_id":"c","thread_id":"thread-json"}"#;
assert_eq!(thread_for_session(web).as_deref(), Some("thread-json"));
@@ -109,7 +115,11 @@ fn record_after_discard_is_dropped_by_the_cancelled_parent() {
let w = ws.path();
// A child registered on the thread (this is how the workspace is learned),
// then the thread is deleted.
- assert!(!mark_stopped_task_if_thread_stopped(w, "thread-race", "sub-reg"));
+ assert!(!mark_stopped_task_if_thread_stopped(
+ w,
+ "thread-race",
+ "sub-reg"
+ ));
discard_for_thread("thread-race");
// A straggler that records after the sweep (the cooperative-abort race) is
// dropped rather than queued.
@@ -129,7 +139,10 @@ fn clear_all_withdraws_every_pending_completion() {
record(w, "sess-c2", "sub-2", "b", Some("t2"));
let removed = clear_all();
- assert!(removed >= 2, "expected at least the two just queued, got {removed}");
+ assert!(
+ removed >= 2,
+ "expected at least the two just queued, got {removed}"
+ );
assert!(pending_ids(w, "t1").is_empty());
assert!(pending_ids(w, "t2").is_empty());
assert_eq!(clear_all(), 0);
@@ -154,10 +167,19 @@ fn record_after_mark_collected_is_dropped() {
let _guard = test_guard();
let ws = workspace();
let w = ws.path();
- assert!(!mark_collected(w, "mc-late"), "nothing queued yet, nothing swept");
+ assert!(
+ !mark_collected(w, "mc-late"),
+ "nothing queued yet, nothing swept"
+ );
// A completion that records *after* (the wait-before-record order) is
// dropped rather than queued for a duplicate delivery turn.
- record(w, "sess-mc-race", "mc-late", "stale", Some("thread-mc-race"));
+ record(
+ w,
+ "sess-mc-race",
+ "mc-late",
+ "stale",
+ Some("thread-mc-race"),
+ );
assert!(pending_ids(w, "thread-mc-race").is_empty());
}
@@ -169,7 +191,13 @@ fn mark_collected_is_task_scoped() {
// Only the collected task is suppressed; an un-waited sibling still
// surfaces (the genuinely-later fire-and-forget feature is preserved).
mark_collected(w, "mc-scope-1");
- record(w, "sess-mc-scope", "mc-scope-2", "later", Some("thread-mc-scope"));
+ record(
+ w,
+ "sess-mc-scope",
+ "mc-scope-2",
+ "later",
+ Some("thread-mc-scope"),
+ );
assert_eq!(pending_ids(w, "thread-mc-scope"), ["mc-scope-2"]);
}
@@ -244,8 +272,20 @@ fn discard_pending_for_thread_blocks_late_results_until_the_next_turn() {
let _guard = test_guard();
let ws = workspace();
let w = ws.path();
- record(w, "sess-stop", "sub-stop-a", "finished before Stop", Some("thread-stop-live"));
- record(w, "sess-stop", "sub-stop-keep", "other thread", Some("thread-stop-other"));
+ record(
+ w,
+ "sess-stop",
+ "sub-stop-a",
+ "finished before Stop",
+ Some("thread-stop-live"),
+ );
+ record(
+ w,
+ "sess-stop",
+ "sub-stop-keep",
+ "other thread",
+ Some("thread-stop-other"),
+ );
// Stop drops the undelivered result so it can't start a delivery turn...
assert_eq!(discard_pending_for_thread("thread-stop-live"), 1);
@@ -254,13 +294,25 @@ fn discard_pending_for_thread_blocks_late_results_until_the_next_turn() {
// A late completion from the stopped generation loses the cooperative
// abort race and is rejected.
- record(w, "sess-stop", "sub-stop-later", "late", Some("thread-stop-live"));
+ record(
+ w,
+ "sess-stop",
+ "sub-stop-later",
+ "late",
+ Some("thread-stop-live"),
+ );
assert!(pending_ids(w, "thread-stop-live").is_empty());
// Completing Stop keeps the thread gate until a new user turn begins, so a
// child that registers after the cancellation sweep is still rejected.
finish_stop_for_thread("thread-stop-live", &["sub-stop-later".into()]);
- record(w, "sess-stop", "sub-stop-later", "again", Some("thread-stop-live"));
+ record(
+ w,
+ "sess-stop",
+ "sub-stop-later",
+ "again",
+ Some("thread-stop-live"),
+ );
assert!(pending_ids(w, "thread-stop-live").is_empty());
// A child that was spawned before Stop but registers after the registry
@@ -272,12 +324,24 @@ fn discard_pending_for_thread_blocks_late_results_until_the_next_turn() {
));
resume_stopped_thread("thread-stop-live");
- record(w, "sess-stop", "sub-stop-registered-late", "late reg", Some("thread-stop-live"));
+ record(
+ w,
+ "sess-stop",
+ "sub-stop-registered-late",
+ "late reg",
+ Some("thread-stop-live"),
+ );
assert!(
pending_ids(w, "thread-stop-live").is_empty(),
"the stopped generation's task ids stay tombstoned after the thread reopens"
);
- record(w, "sess-stop", "sub-stop-new-turn", "next turn", Some("thread-stop-live"));
+ record(
+ w,
+ "sess-stop",
+ "sub-stop-new-turn",
+ "next turn",
+ Some("thread-stop-live"),
+ );
assert_eq!(pending_ids(w, "thread-stop-live"), ["sub-stop-new-turn"]);
}
@@ -292,8 +356,18 @@ fn a_stop_before_a_restart_is_lifted_by_the_first_new_spawn() {
// A restart: the in-memory gate is gone, the durable cancelled-parent
// marker is not.
forget_workspace_for_test(w);
- assert!(!mark_stopped_task_if_thread_stopped(w, "thread-restart-stop", "sub-new"));
- record(w, "sess-rs", "sub-new", "after restart", Some("thread-restart-stop"));
+ assert!(!mark_stopped_task_if_thread_stopped(
+ w,
+ "thread-restart-stop",
+ "sub-new"
+ ));
+ record(
+ w,
+ "sess-rs",
+ "sub-new",
+ "after restart",
+ Some("thread-restart-stop"),
+ );
assert_eq!(
pending_ids(w, "thread-restart-stop"),
["sub-new"],
@@ -306,17 +380,38 @@ fn undelivered_completions_are_found_again_after_a_restart() {
let _guard = test_guard();
let ws = workspace();
let w = ws.path();
- record(w, "sess-boot", "sub-1", "unseen result", Some("thread-boot"));
- record(w, "sess-boot", "sub-2", "delivered result", Some("thread-boot-done"));
+ record(
+ w,
+ "sess-boot",
+ "sub-1",
+ "unseen result",
+ Some("thread-boot"),
+ );
+ record(
+ w,
+ "sess-boot",
+ "sub-2",
+ "delivered result",
+ Some("thread-boot-done"),
+ );
let router = router_for_workspace(w);
- router.claim_pending("thread-boot-done", usize::MAX).unwrap();
+ router
+ .claim_pending("thread-boot-done", usize::MAX)
+ .unwrap();
router.mark_delivered(&["sub-2"]).unwrap();
drop(router);
forget_workspace_for_test(w);
let threads = recover_pending_threads(w);
- assert_eq!(threads, ["thread-boot"], "only the undelivered thread is recovered");
- assert_eq!(pending_for(w, "thread-boot")[0].result.text, "unseen result");
+ assert_eq!(
+ threads,
+ ["thread-boot"],
+ "only the undelivered thread is recovered"
+ );
+ assert_eq!(
+ pending_for(w, "thread-boot")[0].result.text,
+ "unseen result"
+ );
assert!(router_for_thread("thread-boot").is_some());
}
diff --git a/crates/openhuman-core/src/agent/orchestration/background_delivery.rs b/crates/openhuman-core/src/agent/orchestration/background_delivery.rs
index f6a2d2bc5e..c68a78d599 100644
--- a/crates/openhuman-core/src/agent/orchestration/background_delivery.rs
+++ b/crates/openhuman-core/src/agent/orchestration/background_delivery.rs
@@ -70,7 +70,9 @@ fn is_busy(thread_id: &str) -> bool {
.lock()
.expect("background_delivery busy poisoned")
.iter()
- .any(|session| background_completions::thread_for_session(session).as_deref() == Some(thread_id))
+ .any(|session| {
+ background_completions::thread_for_session(session).as_deref() == Some(thread_id)
+ })
}
struct BackgroundDeliveryHandler;
@@ -89,43 +91,49 @@ impl EventHandler<DomainEvent> for BackgroundDeliveryHandler {
.expect("busy poisoned")
.insert(session_id.clone());
}
- DomainEvent::AgentTurnCompleted { session_id, .. } => {
+ // A failed turn may not emit AgentTurnCompleted — clear busy so
+ // delivery isn't stuck.
+ DomainEvent::AgentTurnCompleted { session_id, .. }
+ | DomainEvent::AgentError { session_id, .. } => {
busy().lock().expect("busy poisoned").remove(session_id);
- // A user turn just ended — drain anything that finished while it ran.
- schedule_for_session(session_id, Duration::from_millis(300));
- }
- DomainEvent::AgentError { session_id, .. } => {
- // A failed turn may not emit AgentTurnCompleted — clear busy so
- // delivery isn't stuck, then try to drain.
- busy().lock().expect("busy poisoned").remove(session_id);
- schedule_for_session(session_id, Duration::from_millis(300));
- }
- // Any subagent terminal state — completed, failed, or awaiting-user —
- // can arrive after the parent turn already went idle. Schedule a
- // debounced drain for all three so the pending result is delivered
- // promptly instead of sitting until some unrelated later turn. Only
- // `SubagentCompleted` used to trigger a drain, so a failure (or an
- // awaiting-user pause) after the parent turn went idle left the chat
- // stuck on the original "Accepted" response (#4896). Debounce so a
- // burst batches into a single turn.
- DomainEvent::SubagentCompleted { parent_session, .. }
- | DomainEvent::SubagentFailed { parent_session, .. }
- | DomainEvent::SubagentAwaitingUser { parent_session, .. } => {
- schedule_for_session(parent_session, DEBOUNCE);
}
_ => {}
}
+ if let Some((thread_id, delay)) = drain_schedule(event) {
+ schedule_delivery(thread_id, delay);
+ }
}
}
-/// Schedule a drain for the thread a session belongs to. A session that maps to
-/// no thread (cron, voice, skills) has nothing to deliver into.
-fn schedule_for_session(session_id: &str, delay: Duration) {
- match background_completions::thread_for_session(session_id) {
- Some(thread_id) => schedule_delivery(thread_id, delay),
- None => log::trace!(
- "[background_delivery] session has no delivery thread; not scheduling session={session_id}"
- ),
+/// Which thread to drain, and after how long, for an event. A session that maps
+/// to no thread (cron, voice, skills) has nothing to deliver into.
+fn drain_schedule(event: &DomainEvent) -> Option<(String, Duration)> {
+ let (session, delay) = match event {
+ // A user turn just ended (or failed) — drain anything that finished while
+ // it ran.
+ DomainEvent::AgentTurnCompleted { session_id, .. }
+ | DomainEvent::AgentError { session_id, .. } => (session_id, Duration::from_millis(300)),
+ // Any subagent terminal state — completed, failed, or awaiting-user — can
+ // arrive after the parent turn already went idle. Schedule a debounced
+ // drain for all three so the pending result is delivered promptly instead
+ // of sitting until some unrelated later turn. Only `SubagentCompleted`
+ // used to trigger a drain, so a failure (or an awaiting-user pause) after
+ // the parent turn went idle left the chat stuck on the original
+ // "Accepted" response (#4896). Debounce so a burst batches into a single
+ // turn.
+ DomainEvent::SubagentCompleted { parent_session, .. }
+ | DomainEvent::SubagentFailed { parent_session, .. }
+ | DomainEvent::SubagentAwaitingUser { parent_session, .. } => (parent_session, DEBOUNCE),
+ _ => return None,
+ };
+ match background_completions::thread_for_session(session) {
+ Some(thread_id) => Some((thread_id, delay)),
+ None => {
+ log::trace!(
+ "[background_delivery] session has no delivery thread; not scheduling session={session}"
+ );
+ None
+ }
}
}
@@ -173,9 +181,7 @@ fn claim_ready(router: &CompletionRouter, thread_id: &str) -> Option<Vec<Complet
Ok(batch) if !batch.is_empty() => Some(batch),
Ok(_) => None,
Err(error) => {
- log::error!(
- "[background_delivery] claim failed thread_id={thread_id} error={error}"
- );
+ log::error!("[background_delivery] claim failed thread_id={thread_id} error={error}");
None
}
}
diff --git a/crates/openhuman-core/src/agent/orchestration/background_delivery_tests.rs b/crates/openhuman-core/src/agent/orchestration/background_delivery_tests.rs
index c9cebeb908..485e1e0787 100644
--- a/crates/openhuman-core/src/agent/orchestration/background_delivery_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/background_delivery_tests.rs
@@ -18,11 +18,22 @@ fn workspace() -> tempfile::TempDir {
}
async fn record(ws: &Path, session: &str, task: &str, summary: &str, thread: &str) {
- record_completion(ws, session, task, "researcher", summary, Some(thread.to_owned())).await;
+ record_completion(
+ ws,
+ session,
+ task,
+ "researcher",
+ summary,
+ Some(thread.to_owned()),
+ )
+ .await;
}
fn pending_ids(ws: &Path, thread: &str) -> Vec<String> {
- pending_for(ws, thread).into_iter().map(|r| r.task_id).collect()
+ pending_for(ws, thread)
+ .into_iter()
+ .map(|r| r.task_id)
+ .collect()
}
fn mark_busy(session: &str) {
@@ -48,7 +59,10 @@ async fn claim_takes_the_ready_batch_when_idle() {
assert!(notice.contains("sub-1") && notice.contains("sub-2"));
// The records stay pending (leased) until the turn lands.
assert_eq!(pending_ids(w, "thread-ready").len(), 2);
- assert!(claim_ready(&router, "thread-ready").is_none(), "a held lease is not claimed twice");
+ assert!(
+ claim_ready(&router, "thread-ready").is_none(),
+ "a held lease is not claimed twice"
+ );
}
#[tokio::test]
@@ -104,7 +118,10 @@ async fn a_delivered_batch_is_settled_and_not_redelivered() {
.await;
assert_eq!(turns.load(Ordering::SeqCst), 1);
- assert!(pending_ids(w, "thread-ok").is_empty(), "delivered records are settled");
+ assert!(
+ pending_ids(w, "thread-ok").is_empty(),
+ "delivered records are settled"
+ );
}
#[tokio::test]
@@ -141,7 +158,11 @@ async fn persistence_failure_releases_batch_without_terminal_announcement() {
"the delivery loop must keep a batch whose durable append fails"
);
assert!(
- router.claim_pending("thread-persist", usize::MAX).unwrap().len() == 1,
+ router
+ .claim_pending("thread-persist", usize::MAX)
+ .unwrap()
+ .len()
+ == 1,
"and release it so the next drain can claim it"
);
assert!(
@@ -232,7 +253,8 @@ async fn permanently_failing_delivery_stops_instead_of_retrying_forever() {
record(w, "bd-storm", "sub-2", "beta", "thread-storm").await;
let router = router_for_workspace(w);
- let (turns, undelivered) = drain_until_empty_or(&router, "thread-storm", DEFAULT_MAX_ATTEMPTS * 20).await;
+ let (turns, undelivered) =
+ drain_until_empty_or(&router, "thread-storm", DEFAULT_MAX_ATTEMPTS * 20).await;
assert!(
pending_ids(w, "thread-storm").is_empty(),
@@ -256,19 +278,36 @@ async fn results_that_cannot_be_delivered_are_written_to_the_thread_and_say_so()
let _g = test_guard().await;
let ws = workspace();
let w = ws.path();
- record(w, "bd-undelivered", "sub-7", "the migration plan is ready", "thread-42").await;
+ record(
+ w,
+ "bd-undelivered",
+ "sub-7",
+ "the migration plan is ready",
+ "thread-42",
+ )
+ .await;
let router = router_for_workspace(w);
- let (turns, undelivered) = drain_until_empty_or(&router, "thread-42", DEFAULT_MAX_ATTEMPTS * 20).await;
+ let (turns, undelivered) =
+ drain_until_empty_or(&router, "thread-42", DEFAULT_MAX_ATTEMPTS * 20).await;
assert_eq!(turns, DEFAULT_MAX_ATTEMPTS, "sanity: the turns did run");
let notice = undelivered.expect(
"a batch that exhausted its delivery retries must reach the give-up sink so it can \
be written into the thread; None means the result was silently lost",
);
- assert!(notice.contains("[BACKGROUND_DELIVERY_FAILED]"), "got: {notice}");
- assert!(notice.contains("hosted agent invocation failed"), "got: {notice}");
- assert!(notice.contains("the migration plan is ready"), "got: {notice}");
+ assert!(
+ notice.contains("[BACKGROUND_DELIVERY_FAILED]"),
+ "got: {notice}"
+ );
+ assert!(
+ notice.contains("hosted agent invocation failed"),
+ "got: {notice}"
+ );
+ assert!(
+ notice.contains("the migration plan is ready"),
+ "got: {notice}"
+ );
assert!(notice.contains("sub-7"), "got: {notice}");
}
@@ -294,7 +333,13 @@ async fn transient_failure_under_the_ceiling_keeps_the_result() {
["sub-1"],
"one failed delivery turn must keep the batch, not drop it (#4896)"
);
- assert_eq!(router.claim_pending("thread-transient", usize::MAX).unwrap().len(), 1);
+ assert_eq!(
+ router
+ .claim_pending("thread-transient", usize::MAX)
+ .unwrap()
+ .len(),
+ 1
+ );
}
#[tokio::test]
@@ -320,8 +365,15 @@ async fn busy_deferral_does_not_consume_the_failure_budget() {
}
let pending = pending_for(w, "thread-busy-defer");
- assert_eq!(pending.len(), 1, "deferring while busy never drops the batch");
- assert_eq!(pending[0].attempts, 0, "a busy deferral is not a failed delivery attempt");
+ assert_eq!(
+ pending.len(),
+ 1,
+ "deferring while busy never drops the batch"
+ );
+ assert_eq!(
+ pending[0].attempts, 0,
+ "a busy deferral is not a failed delivery attempt"
+ );
}
#[tokio::test]
@@ -350,11 +402,24 @@ async fn a_pending_completion_survives_a_restart_and_is_delivered() {
let _g = test_guard().await;
let ws = workspace();
let w = ws.path();
- record(w, "bd-restart", "sub-1", "finished before the crash", "thread-restart").await;
+ record(
+ w,
+ "bd-restart",
+ "sub-1",
+ "finished before the crash",
+ "thread-restart",
+ )
+ .await;
// The first delivery attempt is claimed and then the process "dies": the
// lease is in memory only.
let router = router_for_workspace(w);
- assert_eq!(router.claim_pending("thread-restart", usize::MAX).unwrap().len(), 1);
+ assert_eq!(
+ router
+ .claim_pending("thread-restart", usize::MAX)
+ .unwrap()
+ .len(),
+ 1
+ );
drop(router);
forget_workspace_for_test(w);
@@ -370,7 +435,9 @@ async fn a_pending_completion_survives_a_restart_and_is_delivered() {
move |thread, notice| {
let sink = Arc::clone(&sink);
async move {
- sink.lock().expect("sink").push(format!("{thread}|{notice}"));
+ sink.lock()
+ .expect("sink")
+ .push(format!("{thread}|{notice}"));
Ok::<String, String>("presented".into())
}
},
diff --git a/crates/openhuman-core/src/agent/orchestration/completion_notice_tests.rs b/crates/openhuman-core/src/agent/orchestration/completion_notice_tests.rs
index 4ea2194c0d..0d16b80b76 100644
--- a/crates/openhuman-core/src/agent/orchestration/completion_notice_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/completion_notice_tests.rs
@@ -1,7 +1,12 @@
use super::*;
use tinyagents_tasks::CompletionResult;
-fn rec(task: &str, agent: &str, summary: &str, outcome: BackgroundAgentOutcome) -> CompletionRecord {
+fn rec(
+ task: &str,
+ agent: &str,
+ summary: &str,
+ outcome: BackgroundAgentOutcome,
+) -> CompletionRecord {
CompletionRecord::new(
task,
"thread-1",
@@ -26,7 +31,10 @@ fn outcome_round_trips_through_the_harness_status() {
BackgroundAgentOutcome::Failed,
BackgroundAgentOutcome::AwaitingInput,
] {
- assert_eq!(BackgroundAgentOutcome::from_status(outcome.status()), outcome);
+ assert_eq!(
+ BackgroundAgentOutcome::from_status(outcome.status()),
+ outcome
+ );
}
assert_eq!(
BackgroundAgentOutcome::from_status(CompletionStatus::Cancelled),
@@ -63,7 +71,12 @@ fn empty_batch_is_empty() {
#[test]
fn notice_renders_failure_and_awaiting_with_distinct_tags() {
let notice = notice(&[
- rec("sub-ok", "researcher", "all good", BackgroundAgentOutcome::Completed),
+ rec(
+ "sub-ok",
+ "researcher",
+ "all good",
+ BackgroundAgentOutcome::Completed,
+ ),
rec(
"sub-bad",
"researcher",
@@ -106,7 +119,10 @@ fn the_router_formats_with_the_host_wording() {
.formatter()
.format_batch(&[ok("sub-1", "researcher", "done")]);
assert!(text.contains("<background_agent_result id=\"sub-1\""));
- assert!(!text.contains("completed_child_tasks"), "not the harness default wording");
+ assert!(
+ !text.contains("completed_child_tasks"),
+ "not the harness default wording"
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/agent/orchestration/ops.rs b/crates/openhuman-core/src/agent/orchestration/ops.rs
index 1d589a7a36..4c77048854 100644
--- a/crates/openhuman-core/src/agent/orchestration/ops.rs
+++ b/crates/openhuman-core/src/agent/orchestration/ops.rs
@@ -39,12 +39,12 @@ use crate::core::events::DomainEvent;
use std::collections::BTreeMap;
use std::sync::Arc;
use thiserror::Error;
+use tinyagents_harness::ids::TaskId;
+use tinyagents_harness::CancellationToken;
use tinyagents_tasks::{
DetachedTaskRegistry, DetachedTaskRegistryError, DetachedTaskWaitOutcome,
OrchestrationTaskStatus,
};
-use tinyagents_harness::ids::TaskId;
-use tinyagents_harness::CancellationToken;
use tokio::sync::{mpsc, watch};
use tokio::time::{Duration, Instant};
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rs
index 8eb65f5272..d1bc008931 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rs
@@ -27,10 +27,10 @@ use tokio::sync::watch;
use tokio::task::AbortHandle;
use crate::agent::tinyagents::host::steering::shared_steering_registry;
-use tinyagents_tasks::DetachedTaskRegistry;
use tinyagents_harness::ids::TaskId;
use tinyagents_harness::run_queue::RunQueue;
use tinyagents_harness::CancellationToken;
+use tinyagents_tasks::DetachedTaskRegistry;
use super::task_ledger::{record_spawned, task_store_for_workspace};
use tinyagents_orchestration::subagent::{
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/steering.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/steering.rs
index 81bf8f01cb..eb4303e36d 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/steering.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/steering.rs
@@ -2,10 +2,10 @@
//! sub-agent: the `RunQueue` compatibility lane, and the TinyAgents
//! `SteeringHandle` fast path for runs that have registered one.
-use tinyagents_tasks::DetachedTaskRegistryError;
use tinyagents_harness::ids::TaskId;
use tinyagents_harness::run_queue::QueueLane;
use tinyagents_harness::steering::SteeringCommand;
+use tinyagents_tasks::DetachedTaskRegistryError;
use tinyinference_llm::message::Message as TaMessage;
use super::cancel::now_ms;
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger.rs
index 5db94f85d0..2b502a9318 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger.rs
@@ -12,15 +12,15 @@
use std::path::{Path, PathBuf};
use std::sync::{Arc, OnceLock};
-use tinyagents_tasks::{
- open_jsonl_task_store_or_memory, reconcile_orphaned_tasks, InMemoryTaskStore,
- OrchestrationTaskFilter, OrchestrationTaskRecord, TaskStore, TaskStoreRegistry,
-};
use tinyagents_orchestration::subagent::{
list_subagent_records, orphaned_subagent_reason, record_agent_id,
record_cancelled as ledger_cancelled, record_parent_session, record_spawned as ledger_spawned,
subagent_record_for_task, task_status_label, SpawnedSubagent, WaitError,
};
+use tinyagents_tasks::{
+ open_jsonl_task_store_or_memory, reconcile_orphaned_tasks, InMemoryTaskStore,
+ OrchestrationTaskFilter, OrchestrationTaskRecord, TaskStore, TaskStoreRegistry,
+};
/// Where a workspace's detached-task ledger lives.
///
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents_tests.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents_tests.rs
index 0490d7459f..e93c8c1f26 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents_tests.rs
@@ -9,7 +9,6 @@ use crate::agent::tinyagents::host::steering::shared_steering_registry;
use std::path::PathBuf;
use std::sync::Arc;
use std::time::Duration;
-use tinyagents_tasks::OrchestrationTaskStatus;
use tinyagents_harness::ids::TaskId;
use tinyagents_harness::run_queue::{QueueLane, RunQueue};
use tinyagents_harness::steering::{SteeringCommand, SteeringHandle};
@@ -17,6 +16,7 @@ use tinyagents_orchestration::subagent::FinishedOutcome;
use tinyagents_orchestration::subagent::{
DetachedSubagentStatus, WaitError, WaitOutcome, DETACHED_LEDGER_TIMEOUT_MS,
};
+use tinyagents_tasks::OrchestrationTaskStatus;
use tokio::sync::watch;
use tokio::task::AbortHandle;
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents_wire_tests.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents_wire_tests.rs
index 0aaf284d49..dfe023aa08 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents_wire_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents_wire_tests.rs
@@ -6,12 +6,10 @@
use super::*;
use crate::agent::orchestration::running_subagents::roster::snapshot_for_parent;
use crate::agent::orchestration::running_subagents::task_ledger::task_store_for_workspace;
-use tinyagents_tasks::{
- OrchestrationTaskKind, OrchestrationTaskResult, OrchestrationTaskSpec,
-};
use tinyagents_harness::ids::TaskId;
use tinyagents_orchestration::subagent::FinishedOutcome;
use tinyagents_orchestration::subagent::WaitError;
+use tinyagents_tasks::{OrchestrationTaskKind, OrchestrationTaskResult, OrchestrationTaskSpec};
fn spec(id: &str, parent: &str, session: Option<&str>) -> OrchestrationTaskSpec {
let mut spec = OrchestrationTaskSpec::new(
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/list_subagents.rs b/crates/openhuman-core/src/agent/orchestration/tools/list_subagents.rs
index e85661ec15..af62611baf 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/list_subagents.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/list_subagents.rs
@@ -10,9 +10,9 @@ use crate::agent::orchestration::{
use async_trait::async_trait;
use serde_json::json;
use std::sync::Arc;
-use tinyagents_tasks::{OrchestrationTaskRecord, OrchestrationTaskStatus};
use tinyagents_harness::context::RunContext;
use tinyagents_harness::tool::{ToolDispatch, ToolExecutionContext};
+use tinyagents_tasks::{OrchestrationTaskRecord, OrchestrationTaskStatus};
use tinytools::{PermissionLevel, Tool, ToolCallOptions, ToolResult, ToolRunContext};
pub struct ListSubagentsTool;
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/steering.rs b/crates/openhuman-core/src/agent/tinyagents/host/steering.rs
index 4817b955ea..d0450f9143 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/steering.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/steering.rs
@@ -2,10 +2,10 @@
use std::sync::OnceLock;
-use tinyagents_tasks::SteeringRegistry;
#[cfg(test)]
use tinyagents_harness::ids::TaskId;
use tinyagents_harness::steering::{SteeringCommandKind, SteeringHandle, SteeringPolicy};
+use tinyagents_tasks::SteeringRegistry;
static STEERING_REGISTRY: OnceLock<SteeringRegistry> = OnceLock::new();