Skip to content

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

refactor(orchestration): simplify owner lookups and re-exports

Steven Enamakel477c98d2b4f4
diff --git a/crates/openhuman-core/src/agent/orchestration/completion_owners.rs b/crates/openhuman-core/src/agent/orchestration/completion_owners.rs
index eafc62e39e..0d06505617 100644
--- a/crates/openhuman-core/src/agent/orchestration/completion_owners.rs
+++ b/crates/openhuman-core/src/agent/orchestration/completion_owners.rs
@@ -141,13 +141,13 @@ pub(crate) fn driver_tasks_for_thread(
let profile = ctx.tenant().ok().and_then(|tenant| tenant.profile);
owners()
.driver_tasks
- .iter()
- .filter_map(|(_, owner)| {
- (owner.profile == profile
+ .values()
+ .filter(|owner| {
+ owner.profile == profile
&& owner.workspace_dir == workspace_dir
- && owner.parent_thread_id.as_deref() == Some(thread_id))
- .then(|| (owner.task_id.clone(), owner.clone()))
+ && owner.parent_thread_id.as_deref() == Some(thread_id)
})
+ .map(|owner| (owner.task_id.clone(), owner.clone()))
.collect()
}
@@ -159,13 +159,13 @@ pub(crate) fn driver_tasks_for_parent(
let profile = ctx.tenant().ok().and_then(|tenant| tenant.profile);
owners()
.driver_tasks
- .iter()
- .filter_map(|(_, owner)| {
- (owner.profile == profile
+ .values()
+ .filter(|owner| {
+ owner.profile == profile
&& owner.workspace_dir == workspace_dir
- && owner.parent_session == parent_session)
- .then(|| (owner.task_id.clone(), owner.clone()))
+ && owner.parent_session == parent_session
})
+ .map(|owner| (owner.task_id.clone(), owner.clone()))
.collect()
}
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/roster.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/roster.rs
index 35749913c2..28238ea35d 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/roster.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/roster.rs
@@ -123,12 +123,10 @@ pub(crate) async fn active_subagents_context_block(
workspace: Option<&tinytools::WorkspaceDescriptor>,
) -> Option<String> {
admit_workspace(ctx, workspace_dir).ok()?;
- let Some(thread_id) = crate::agent::orchestration::background_completions::thread_for_session(
+ let thread_id = crate::agent::orchestration::background_completions::thread_for_session(
ctx,
parent_session,
- ) else {
- return None;
- };
+ )?;
let jobs = crate::core::runtime::slot_for::<
tinyagents_harness_tools::subagents::SubAgentJobRegistry,
>(ctx);
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/mod.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/mod.rs
index 837b9dbc81..ff4a694aa8 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/mod.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/mod.rs
@@ -7,15 +7,15 @@ mod tiny_port;
mod tiny_port_epoch;
mod types;
+#[cfg(test)]
+pub(crate) use ops::cancel_driver_job_by_task;
pub use ops::{
action_root_key, cancel_driver_job_for_observed_session, cancel_driver_jobs_for_thread,
- close_if_current, find_reusable, list_for_parent, mark_failed,
- mark_finished, normalize_task_key, resolve_driver_lifecycle_key, resolve_lifecycle_key,
- reuse_decision, upsert_running, DriverTaskCancellation,
+ close_if_current, find_reusable, list_for_parent, mark_failed, mark_finished,
+ normalize_task_key, resolve_driver_lifecycle_key, resolve_lifecycle_key, reuse_decision,
+ upsert_running, DriverTaskCancellation,
};
#[cfg(test)]
-pub(crate) use ops::cancel_driver_job_by_task;
-#[cfg(test)]
pub(crate) use tiny_port::OpenHumanTinySubagentSessionStore;
pub(crate) use tiny_port::{host_projection, import_terminal_task_for_context, open_for_context};
pub(crate) use tiny_port_epoch::{parent_epoch_for_context, set_parent_epoch_for_context};
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rs
index ea1506d42f..816aa81c6b 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rs
@@ -13,12 +13,12 @@ use super::types::{
mod driver;
#[cfg(test)]
use driver::record_cancel_reason;
+#[cfg(test)]
+pub(crate) use driver::{cancel_driver_job_by_task, mark_driver_pause_cancelled};
pub use driver::{
cancel_driver_job_for_observed_session, cancel_driver_jobs_for_thread,
resolve_driver_lifecycle_key, resolve_lifecycle_key, DriverTaskCancellation,
};
-#[cfg(test)]
-pub(crate) use driver::{cancel_driver_job_by_task, mark_driver_pause_cancelled};
pub use tinyagents_orchestration::subagent::normalize_task_key;
pub fn action_root_key(path: Option<&Path>) -> Option<String> {
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_continuation_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_continuation_tests.rs
index a990bbc97c..e9ec21851a 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_continuation_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_continuation_tests.rs
@@ -383,7 +383,7 @@ async fn spawn_subagent_with_same_task_key_resumes_paused_job_through_shared_dri
.expect("resume completion projection follows durable settlement");
assert!(provider.saw("Inspect the README and continue."));
assert_eq!(provider.calls.load(std::sync::atomic::Ordering::SeqCst), 2);
- let requests = provider.seen.lock();
+ let requests = provider.seen.lock().clone();
assert_eq!(requests.len(), 2);
let resumed_request = &requests[1];
assert!(resumed_request.contains("Investigate the pause-resume fixture"));
@@ -395,8 +395,6 @@ async fn spawn_subagent_with_same_task_key_resumes_paused_job_through_shared_dri
1,
"the answer is appended to the resumed history exactly once"
);
- drop(requests);
-
let completed_job = jobs
.get(paused_job.id.as_str())
.expect("continuation reuses the same registered job");