The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(agent): validate reusable subagent session against resolved lifecycle key
Steven Enamakelfd66d6e6cce8
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_host_impl.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_host_impl.rsindex 6958a29fec..f20328b424 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_host_impl.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_host_impl.rs@@ -244,6 +244,20 @@ impl SpawnSubagentTool {));};let checkpoint_dir = parent.workspace_dir.join(".openhuman/subagent_checkpoints");+ let original_key = match subagent_sessions::resolve_lifecycle_key(+ &store,+ &session.subagent_session_id,+ &parent_session,+ parent_thread_id.as_deref(),+ &checkpoint_dir,+ ) {+ Ok(key) => key,+ Err(error) => {+ return Ok(ToolResult::error(format!(+ "spawn_subagent: reusable session has no valid lifecycle key: {error}"+ )));+ }+ };let checkpoint = match crate::agent::subagent_host::load_subagent_checkpoint(&checkpoint_dir,task_id,@@ -255,12 +269,10 @@ impl SpawnSubagentTool {)));}};- let Some(original_key) = checkpoint.task_key.clone() else {- return Ok(ToolResult::error(- "spawn_subagent: paused checkpoint omitted its original task key",- ));- };- if checkpoint.agent_id != definition.id || original_key.task_id != task_id {+ if checkpoint.agent_id != definition.id+ || checkpoint.task_id != task_id+ || checkpoint.task_key.as_ref() != Some(&original_key)+ {return Ok(ToolResult::error("spawn_subagent: paused checkpoint does not match the reusable session",));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.rsindex df07a29c77..4d9f50a9c1 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@@ -126,6 +126,15 @@ async fn spawn_subagent_with_same_task_key_resumes_paused_job_through_shared_dri.find(|session| session.current_task_id.as_deref() == Some(task_id.as_str())).expect("initial durable session points at the paused child");assert_eq!(before_session.status, DurableSubagentStatus::AwaitingUser);+ let original_lifecycle_key = before_session+ .lifecycle_key+ .clone()+ .expect("paused session retains its original TinyAgents task key");+ assert_eq!(original_lifecycle_key.task_id, task_id);+ assert_eq!(+ original_lifecycle_key.thread_id.as_deref(),+ Some("continue-paused-e2e-thread")+ );let before_job_count = jobs.list().len();let resumed = SpawnSubagentTool::new()@@ -210,6 +219,17 @@ async fn spawn_subagent_with_same_task_key_resumes_paused_job_through_shared_dricompleted_job.output.as_deref(),Some("paused-child-resumed-answer"));+ let completed_session = sessions+ .load()+ .expect("completed session list")+ .into_iter()+ .find(|session| session.current_task_id.as_deref() == Some(task_id.as_str()))+ .expect("completed row still owns the original task");+ assert_eq!(+ completed_session.lifecycle_key.as_ref(),+ Some(&original_lifecycle_key),+ "resume preserves the original lifecycle identity"+ );}fn core_backed_live_parent(