Skip to content

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

fix(agent): scope task store resolution to the resolved context

Steven Enamakel3664f71a8328
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/resolve.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/resolve.rs
index fc7bb03c8b..9d78491635 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/resolve.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/resolve.rs
@@ -93,10 +93,17 @@ pub(crate) fn resume_ref_for_task_in_workspace(
Ok(reference)
}
-fn scoped_task_store(
+pub(super) fn scoped_task_store(
ctx: &crate::core::runtime::DispatchCtx,
workspace_dir: &Path,
) -> Result<std::sync::Arc<dyn tinyagents_tasks::TaskStore>, WaitError> {
- let _ = ctx;
+ if let Some(context) = ctx.resolved() {
+ return Ok(crate::core::runtime::CoreContext::sync_scope(context, || {
+ task_store_for_workspace(workspace_dir)
+ }));
+ }
+ if crate::core::runtime::is_saas() {
+ return Err(WaitError::NotOwned);
+ }
Ok(task_store_for_workspace(workspace_dir))
}
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/wait.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/wait.rs
index 81fd1c6012..9546f70afa 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/wait.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/wait.rs
@@ -26,9 +26,7 @@ pub(crate) async fn wait(
return wait_detached(registry(), task_id, &owner, timeout).await;
};
admit_workspace(ctx, &workspace_dir)?;
- let store = crate::core::runtime::CoreContext::sync_scope(context, || {
- super::task_ledger::task_store_for_workspace(&workspace_dir)
- });
+ let store = super::resolve::scoped_task_store(ctx, &workspace_dir)?;
wait_detached_or_durable(
registry(),
store.as_ref(),
@@ -49,10 +47,7 @@ pub(crate) async fn wait_in_workspace(
) -> Result<WaitOutcome, WaitError> {
admit_workspace(ctx, workspace_dir)?;
let owner = owner_key(ctx, parent_session)?;
- let context = ctx.resolved().ok_or(WaitError::NotOwned)?;
- let store = crate::core::runtime::CoreContext::sync_scope(context, || {
- super::task_ledger::task_store_for_workspace(workspace_dir)
- });
+ let store = super::resolve::scoped_task_store(ctx, workspace_dir)?;
wait_detached_or_durable(
registry(),
store.as_ref(),