Skip to content

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

refactor(orchestration): build subagent session stores via context

Steven Enamakel7b00b77dc53b
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rs
index 1e19334f4c..fd94bd6a1d 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rs
@@ -54,9 +54,10 @@ pub(crate) fn cancel_by_task_with_workspace_reason(
let Some(workspace_dir) = workspace_dir else {
return Ok(None);
};
- let store = crate::agent::orchestration::subagent_sessions::SubagentSessionStore::new(
+ let store = crate::agent::orchestration::subagent_sessions::SubagentSessionStore::new_in_context(
+ ctx,
workspace_dir.clone(),
- );
+ )?;
let jobs = crate::core::runtime::slot_for::<
tinyagents_harness_tools::subagents::SubAgentJobRegistry,
>(ctx);
@@ -145,14 +146,19 @@ pub(crate) fn stop_for_thread(
tinyagents_harness_tools::subagents::SubAgentJobRegistry,
>(ctx);
let driver_stopped =
- crate::agent::orchestration::subagent_sessions::cancel_driver_jobs_for_thread(
- &crate::agent::orchestration::subagent_sessions::SubagentSessionStore::new(
- workspace_dir.clone(),
- ),
+ crate::agent::orchestration::subagent_sessions::SubagentSessionStore::new_in_context(
+ ctx,
+ workspace_dir.clone(),
+ )
+ .map(|store| {
+ crate::agent::orchestration::subagent_sessions::cancel_driver_jobs_for_thread(
+ &store,
&workspace_dir,
&jobs,
thread_id,
- );
+ )
+ })
+ .unwrap_or_default();
for task_id in driver_stopped {
if !task_ids.contains(&task_id) {
task_ids.push(task_id);
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 6c294f9039..9500e80183 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/roster.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/roster.rs
@@ -103,20 +103,16 @@ pub(crate) fn active_subagents_context_block(
workspace_dir: &std::path::Path,
) -> Option<String> {
admit_workspace(ctx, workspace_dir).ok()?;
- let store = crate::agent::orchestration::subagent_sessions::SubagentSessionStore {
- workspace_dir: workspace_dir.to_path_buf(),
- };
- let load = || {
- crate::agent::orchestration::subagent_sessions::list_for_parent(
- &store,
- parent_session,
- None,
- )
- };
- let durable = match ctx.resolved() {
- Some(context) => crate::core::runtime::CoreContext::sync_scope(context, load),
- None => load(),
- };
+ let store = crate::agent::orchestration::subagent_sessions::SubagentSessionStore::new_in_context(
+ ctx,
+ workspace_dir.to_path_buf(),
+ )
+ .ok()?;
+ let durable = crate::agent::orchestration::subagent_sessions::list_for_parent(
+ &store,
+ parent_session,
+ None,
+ );
let durable: Vec<DurableSubagentSessionSummary> = match durable {
Ok(sessions) => sessions
.into_iter()