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(subagent_sessions): resolve reusable driver sessions from the driver store
Steven Enamakelfad2bb73944a
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/mod.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/mod.rsindex ca0b4823f5..34c4ce8146 100644--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/mod.rs+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/mod.rs@@ -14,7 +14,9 @@ pub use ops::{};#[cfg(test)]pub(crate) use tiny_port::OpenHumanTinySubagentSessionStore;-pub(crate) use tiny_port::{host_projection, open_for_context, set_parent_epoch_for_context};+pub(crate) use tiny_port::{+ host_projection, open_for_context, parent_epoch_for_context, set_parent_epoch_for_context,+};pub use types::{DurableSubagentStatus, SubagentSessionSelector, SubagentSessionStore, SubagentSessionUpsert,};diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/tiny_port.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/tiny_port.rsindex 63821f59f1..e07a932e8d 100644--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/tiny_port.rs+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/tiny_port.rs@@ -57,6 +57,30 @@ pub(crate) fn parent_epoch_from_sidecar(.map_err(|error| SubagentError::Persistence(format!("read parent epoch: {error}")))}+pub(crate) fn parent_epoch_for_context(+ ctx: &crate::core::runtime::DispatchCtx,+ workspace_dir: &std::path::Path,+ session_id: String,+) -> Result<Option<u64>, SubagentError> {+ let open_documents = || {+ let opened =+ crate::storage::local::open("subagent_sessions", workspace_dir).map_err(|error| {+ SubagentError::Persistence(format!("open session store: {error:#}"))+ })?;+ let scoped = opened.scoped().map_err(|error| {+ SubagentError::Persistence(format!("scope session store: {error:#}"))+ })?;+ Ok::<_, SubagentError>(Arc::clone(scoped.documents()))+ };+ let context = ctx.resolved().ok_or_else(|| {+ SubagentError::Persistence("subagent session store has no resolved owner scope".into())+ })?;+ parent_epoch_from_sidecar(+ crate::core::runtime::CoreContext::sync_scope(context, open_documents)?,+ session_id,+ )+}+pub(crate) fn set_parent_epoch_for_context(ctx: &crate::core::runtime::DispatchCtx,workspace_dir: &std::path::Path,diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_driver_lookup.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_driver_lookup.rsindex b09c2e85fb..9b3ead99e0 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_driver_lookup.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_driver_lookup.rs@@ -1,6 +1,7 @@async fn find_reusable_driver_session(driver: &std::sync::Arc<dyn tinyagents_orchestration::subagent::SubagentSessionStore>,- legacy: &SubagentSessionStore,+ ctx: &DispatchCtx,+ workspace_dir: &std::path::Path,selector: &SubagentSessionSelector,) -> Result<Option<DurableSubagentSession>, String> {let driver_selector = tinyagents_orchestration::subagent::SubagentSessionSelector {@@ -25,15 +26,16 @@ async fn find_reusable_driver_session() else {return Ok(None);};-- legacy- .load()- .map(|sessions| {- sessions.into_iter().find(|session| {- session.subagent_session_id == selected.subagent_session_id- && session.matches_selector(selector)- })- })+ let parent_epoch = subagent_sessions::parent_epoch_for_context(+ ctx,+ workspace_dir,+ selected.subagent_session_id.clone(),+ )+ .map_err(|error| error.to_string())?;+ Ok(Some(subagent_sessions::host_projection(+ selected,+ parent_epoch,+ )))}async fn upsert_driver_session(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 0df4bef138..faa2b34e6f 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@@ -155,7 +155,14 @@ impl SpawnSubagentTool {};let reusable = if force_fresh {- match find_reusable_driver_session(&driver_store, &store, &selector).await {+ match find_reusable_driver_session(+ &driver_store,+ &dispatch,+ &parent.workspace_dir,+ &selector,+ )+ .await+ {Ok(Some(session)) => {let jobs = crate::core::runtime::slot_for::<tinyagents_harness_tools::subagents::SubAgentJobRegistry,@@ -203,7 +210,14 @@ impl SpawnSubagentTool {}None} else {- match find_reusable_driver_session(&driver_store, &store, &selector).await {+ match find_reusable_driver_session(+ &driver_store,+ &dispatch,+ &parent.workspace_dir,+ &selector,+ )+ .await+ {Ok(session) => session,Err(err) => {log::warn!(