Skip to content

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

fix(running_subagents): scope durable wait and resolve lookups to the parent session

Steven Enamakele290c8b43c2b
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 599ddaa6ab..ca37b4c580 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/resolve.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/resolve.rs
@@ -6,8 +6,9 @@
use std::path::Path;
use tinyagents_orchestration::subagent::{
- resolve_detached_or_durable, resume_ref_for_task as live_resume_ref_for_task,
- task_id_for_session as live_task_id_for_session, SubagentResumeRef, WaitError,
+ resolve_detached_or_durable_with_owners, resume_ref_for_task as live_resume_ref_for_task,
+ task_id_for_session as live_task_id_for_session, DetachedSubagentOwners, SubagentResumeRef,
+ WaitError,
};
use super::registry::{admit_workspace, owner_key, registry};
@@ -39,8 +40,13 @@ pub(crate) fn task_id_for_session_in_workspace(
admit_workspace(ctx, workspace_dir)?;
let owner = owner_key(ctx, parent_session)?;
let store = scoped_task_store(ctx, workspace_dir)?;
- let resolved =
- resolve_detached_or_durable(registry(), store.as_ref(), subagent_session_id, &owner)?;
+ let owners = DetachedSubagentOwners::new(&owner, parent_session);
+ let resolved = resolve_detached_or_durable_with_owners(
+ registry(),
+ store.as_ref(),
+ subagent_session_id,
+ &owners,
+ )?;
let task_id = resolved.task_id;
log::debug!(
"[running_subagents] resolved session from task store subagent_session_id={} task_id={} workspace_dir={}",
@@ -75,7 +81,9 @@ pub(crate) fn resume_ref_for_task_in_workspace(
admit_workspace(ctx, workspace_dir)?;
let owner = owner_key(ctx, parent_session)?;
let store = scoped_task_store(ctx, workspace_dir)?;
- let reference = resolve_detached_or_durable(registry(), store.as_ref(), task_id, &owner)?;
+ let owners = DetachedSubagentOwners::new(&owner, parent_session);
+ let reference =
+ resolve_detached_or_durable_with_owners(registry(), store.as_ref(), task_id, &owners)?;
log::debug!(
"[running_subagents] resolved resume ref from task store task_id={} workspace_dir={}",
task_id,
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 9546f70afa..7b28072546 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/wait.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/wait.rs
@@ -6,7 +6,8 @@ use std::path::Path;
use std::time::Duration;
use tinyagents_orchestration::subagent::{
- wait_detached, wait_detached_or_durable, WaitError, WaitOutcome,
+ wait_detached, wait_detached_or_durable_with_owners, DetachedSubagentOwners, WaitError,
+ WaitOutcome,
};
use super::registry::{admit_workspace, owner_key, registry};
@@ -27,12 +28,13 @@ pub(crate) async fn wait(
};
admit_workspace(ctx, &workspace_dir)?;
let store = super::resolve::scoped_task_store(ctx, &workspace_dir)?;
- wait_detached_or_durable(
+ let owners = DetachedSubagentOwners::new(&owner, parent_session);
+ wait_detached_or_durable_with_owners(
registry(),
store.as_ref(),
&super::super::background_completions::router_for_workspace_ctx(ctx, &workspace_dir),
task_id,
- &owner,
+ &owners,
timeout,
)
.await
@@ -48,12 +50,13 @@ pub(crate) async fn wait_in_workspace(
admit_workspace(ctx, workspace_dir)?;
let owner = owner_key(ctx, parent_session)?;
let store = super::resolve::scoped_task_store(ctx, workspace_dir)?;
- wait_detached_or_durable(
+ let owners = DetachedSubagentOwners::new(&owner, parent_session);
+ wait_detached_or_durable_with_owners(
registry(),
store.as_ref(),
&super::super::background_completions::router_for_workspace_ctx(ctx, workspace_dir),
task_id,
- &owner,
+ &owners,
timeout,
)
.await
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents_tenant_tests.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents_tenant_tests.rs
index f2e7b050ff..0f5d220d75 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents_tenant_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents_tenant_tests.rs
@@ -676,4 +676,33 @@ async fn durable_fallback_store_uses_explicit_profile_context_at_shared_workspac
resume_ref_for_task_in_workspace(&bob, &task_id, PARENT, workspace.path()),
Err(WaitError::Unknown)
));
+ assert!(
+ matches!(
+ super::super::wait_in_workspace(
+ &alice,
+ &task_id,
+ PARENT,
+ workspace.path(),
+ std::time::Duration::ZERO,
+ )
+ .await,
+ Ok(tinyagents_orchestration::subagent::WaitOutcome::TimedOut(
+ tinyagents_orchestration::subagent::DetachedSubagentStatus::Running
+ )),
+ ),
+ "Alice's scoped durable wait must read her running row after registry miss"
+ );
+ assert_eq!(
+ super::super::wait_in_workspace(
+ &bob,
+ &task_id,
+ PARENT,
+ workspace.path(),
+ std::time::Duration::ZERO,
+ )
+ .await
+ .unwrap_err(),
+ WaitError::Unknown,
+ "Bob's profile store must not expose Alice's task"
+ );
}