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
feat(subagent_sessions): resolve lifecycle key for saved sessions
Steven Enamakel8bbb97c50e2d
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/mod.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/mod.rsindex e19299551a..ea95d0c743 100644--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/mod.rs+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/mod.rs@@ -5,7 +5,8 @@ mod types;pub use ops::{action_root_key, close, find_reusable, list_for_parent, mark_failed, mark_finished,- normalize_task_key, reuse_decision, task_title_from_prompt, upsert_running,+ normalize_task_key, resolve_lifecycle_key, reuse_decision, task_title_from_prompt,+ upsert_running,};pub use types::{DurableSubagentSessionSummary, DurableSubagentStatus, SubagentSessionSelector,diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rsindex 31f644b4ce..ff40a547aa 100644--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rs+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rs@@ -13,6 +13,44 @@ use super::types::{SubagentSessionStore, SubagentSessionUpsert,};+/// Resolve a saved product session to its exact TinyAgents lifecycle key.+///+/// The product session lookup is scoped by the authenticated parent session,+/// optional parent thread, and the workspace-specific store. Rows written+/// before `lifecycle_key` was added recover it only from the matching host+/// checkpoint; a public task id alone is never treated as a lifecycle key.+pub fn resolve_lifecycle_key(+ store: &SubagentSessionStore,+ session_or_task_id: &str,+ parent_session: &str,+ parent_thread_id: Option<&str>,+ checkpoint_dir: &Path,+) -> Result<tinyagents_orchestration::subagent::SubagentTaskKey, String> {+ let session = list_for_parent(store, parent_session, parent_thread_id)?+ .into_iter()+ .find(|session| {+ session.subagent_session_id == session_or_task_id+ || session.current_task_id.as_deref() == Some(session_or_task_id)+ })+ .ok_or_else(|| "durable subagent session not found".to_string())?;+ let task_id = session+ .current_task_id+ .as_deref()+ .ok_or_else(|| "durable subagent session has no current task".to_string())?;+ let key = if let Some(key) = session.lifecycle_key {+ key+ } else {+ crate::agent::subagent_host::load_subagent_checkpoint(checkpoint_dir, task_id)+ .map_err(|error| format!("legacy subagent checkpoint unavailable: {error}"))?+ .task_key+ .ok_or_else(|| "legacy subagent checkpoint has no lifecycle key".to_string())?+ };+ if key.task_id != task_id || key.thread_id.as_deref() != session.parent_thread_id.as_deref() {+ return Err("durable subagent lifecycle key does not match its owned session".into());+ }+ Ok(key)+}+pub fn normalize_task_key(input: &str) -> String {let mut out = String::new();let mut last_dash = false;diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops_tests.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops_tests.rsindex 20d2b95244..fd9304ca6a 100644--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops_tests.rs@@ -106,6 +106,23 @@ fn upsert_persists_the_full_lifecycle_key_without_collapsing_to_task_id() {.unwrap();assert_eq!(loaded.current_task_id.as_deref(), Some("sub-1"));assert_eq!(loaded.lifecycle_key, Some(key));+ let resolved = resolve_lifecycle_key(+ &store,+ &session.subagent_session_id,+ "parent-a",+ Some("thread-a"),+ dir.path(),+ )+ .unwrap();+ assert_eq!(resolved, key);+ assert!(resolve_lifecycle_key(+ &store,+ &session.subagent_session_id,+ "another-parent",+ Some("thread-a"),+ dir.path(),+ )+ .is_err());}#[test]