Skip to content

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

test(orchestration): scope e2e job lookups to parent owner

Steven Enamakel918b5e5b3c65
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 141f523bd0..d4f0dd4f05 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
@@ -157,6 +157,43 @@ async fn spawn_subagent_with_same_task_key_resumes_paused_job_through_shared_dri
sessions
.save(&mismatched_records)
.expect("corrupt only the persisted lifecycle owner key");
+ let definition = AgentDefinitionRegistry::builtins_only()
+ .get("task_manager_agent")
+ .expect("task manager definition");
+ let selector = crate::agent::orchestration::subagent_sessions::SubagentSessionSelector {
+ parent_session: "continue-paused-e2e".into(),
+ parent_thread_id: Some("continue-paused-e2e-thread".into()),
+ agent_id: "task_manager_agent".into(),
+ model: Some("test-model".into()),
+ sandbox_mode: format!("{:?}", definition.sandbox_mode),
+ action_root: None,
+ task_key: "pause-resume-fixture".into(),
+ };
+ let (saved_key, reusable_session_id) =
+ crate::core::runtime::CoreContext::sync_scope(Arc::clone(&_core), || {
+ let reread = sessions.load().expect("reread corrupted paused row");
+ let persisted = reread
+ .iter()
+ .find(|session| {
+ session.subagent_session_id == before_session.subagent_session_id
+ })
+ .expect("corrupted paused row remains persisted");
+ let reusable = crate::agent::orchestration::subagent_sessions::find_reusable(
+ &sessions,
+ &selector,
+ )
+ .expect("find matching paused session")
+ .expect("the exact spawn selector still selects the paused session");
+ (
+ persisted.lifecycle_key.clone().expect("persisted key"),
+ reusable.subagent_session_id,
+ )
+ });
+ assert_ne!(saved_key, original_lifecycle_key);
+ assert_eq!(
+ reusable_session_id, before_session.subagent_session_id,
+ "the production reuse selector sees the corrupted paused row"
+ );
let refused_resume = SpawnSubagentTool::new()
.execute_with_live_parent_context(
json!({
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_control_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_control_tests.rs
index a5b7640356..33a6f02424 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_control_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_control_tests.rs
@@ -104,8 +104,18 @@ async fn unscoped_web_stop_cancels_a_running_driver_subagent() {
let jobs = crate::core::runtime::slot_for::<
tinyagents_harness_tools::subagents::SubAgentJobRegistry,
>(&dispatch);
+ let owner = crate::agent::tinyagents::tool_registration::subagent_owner_key(
+ workspace.path(),
+ "stop-detached-subagent-session",
+ Some(thread_id),
+ );
+ let parent_scope = tinyagents_orchestration::subagent::ParentJobScope::new(
+ tinytools::WorkspaceDescriptor::new(workspace.path()),
+ thread_id,
+ );
let job = jobs
- .list()
+ .list_for_parent_scope(&owner, &parent_scope)
+ .expect("read owner-scoped driver jobs")
.into_iter()
.find(|job| {
job.extensions
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_profile_cancel_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_profile_cancel_tests.rs
index edb20307ff..a5940ac9c5 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_profile_cancel_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_profile_cancel_tests.rs
@@ -147,8 +147,18 @@ async fn profile_scope_cannot_cancel_another_profiles_driver_child() {
let alice_jobs = crate::core::runtime::slot_for::<
tinyagents_harness_tools::subagents::SubAgentJobRegistry,
>(&alice_ctx);
+ let alice_owner = crate::agent::tinyagents::tool_registration::subagent_owner_key(
+ &workspace,
+ "shared-profile-parent-session",
+ Some(thread_id),
+ );
+ let parent_scope = tinyagents_orchestration::subagent::ParentJobScope::new(
+ tinytools::WorkspaceDescriptor::new(&workspace),
+ thread_id,
+ );
let alice_job = alice_jobs
- .list()
+ .list_for_parent_scope(&alice_owner, &parent_scope)
+ .expect("read Alice's owner-scoped driver jobs")
.into_iter()
.find(|job| {
job.extensions