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
refactor(orchestration): pass SpawnedSubagent struct to ledger
Steven Enamakele735eaa46084
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rsindex 75a9caa959..15a3eaa441 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rs@@ -36,7 +36,7 @@ use tinyagents_tasks::DetachedTaskRegistry;use super::resolve::scoped_task_store;use super::task_ledger::record_spawned_in_store;use tinyagents_orchestration::subagent::{- spawn_status_watcher, DetachedSubagentStatus, SubagentIdentity, WaitError,+ spawn_status_watcher, DetachedSubagentStatus, SpawnedSubagent, SubagentIdentity, WaitError,};#[derive(Clone)]@@ -250,15 +250,18 @@ pub(crate) fn register(RegistrationError::Registry(error)})?;// Failed admission must not leave a Running lifecycle record or watcher.+ let workspace = workspace_dir.display().to_string();record_spawned_in_store(task_store.as_ref(),- &task_id,- &agent_id,- &parent_session,- session_parent_prefix.as_deref(),- subagent_session_id.as_deref(),- &workspace_dir,- parent_thread_id.as_deref(),+ &SpawnedSubagent {+ task_id: &task_id,+ agent_id: &agent_id,+ parent_session: &parent_session,+ session_parent_prefix: session_parent_prefix.as_deref(),+ subagent_session_id: subagent_session_id.as_deref(),+ workspace_dir: &workspace,+ parent_thread_id: parent_thread_id.as_deref(),+ },);spawn_status_watcher(task_store, task_id.clone(), status);log::debug!(diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger.rsindex d07e82fee8..f48cbb1d98 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger.rs@@ -106,6 +106,7 @@ fn task_store() -> Arc<dyn TaskStore> {/// Record a freshly-spawned sub-agent in the workspace's store (`Pending` →/// `Running`). Insert errors (e.g. a re-used task id across tests) are ignored.+#[cfg(test)]pub(crate) fn record_spawned(task_id: &str,agent_id: &str,@@ -115,43 +116,24 @@ pub(crate) fn record_spawned(workspace_dir: &Path,parent_thread_id: Option<&str>,) {- record_spawned_in_store(- task_store_for_workspace(workspace_dir).as_ref(),+ let workspace = workspace_dir.display().to_string();+ let record = SpawnedSubagent {task_id,agent_id,parent_session,session_parent_prefix,subagent_session_id,- workspace_dir,+ workspace_dir: &workspace,parent_thread_id,- );+ };+ record_spawned_in_store(task_store_for_workspace(workspace_dir).as_ref(), &record);}-pub(crate) fn record_spawned_in_store(- store: &dyn TaskStore,- task_id: &str,- agent_id: &str,- parent_session: &str,- session_parent_prefix: Option<&str>,- subagent_session_id: Option<&str>,- workspace_dir: &Path,- parent_thread_id: Option<&str>,-) {- let workspace = workspace_dir.display().to_string();- if let Err(err) = ledger_spawned(- store,- &SpawnedSubagent {- task_id,- agent_id,- parent_session,- session_parent_prefix,- subagent_session_id,- workspace_dir: &workspace,- parent_thread_id,- },- ) {+pub(crate) fn record_spawned_in_store(store: &dyn TaskStore, spawned: &SpawnedSubagent<'_>) {+ if let Err(err) = ledger_spawned(store, spawned) {log::debug!(- "[running_subagents] spawn ledger insert ignored task_id={task_id} error={err}"+ "[running_subagents] spawn ledger insert ignored task_id={} error={err}",+ spawned.task_id);}}