Skip to content

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

fix(subagent_sessions): require 'static closures in session update callbacks

Steven Enamakelea5f94ef8ec6
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rs
index 33237d43fd..282b635f09 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rs
@@ -180,9 +180,11 @@ pub fn mark_finished(
run_status: &SubagentRunStatus,
history: Vec<TranscriptMessage>,
) -> Result<(), String> {
+ let task_id = task_id.to_owned();
+ let status = DurableSubagentStatus::from_run_status(run_status);
let updated = update_session(store, subagent_session_id, |session, now| {
- session.current_task_id = Some(task_id.to_string());
- session.status = DurableSubagentStatus::from_run_status(run_status);
+ session.current_task_id = Some(task_id.clone());
+ session.status = status;
session.latest_history = Some(history.clone());
session.latest_error = None;
session.updated_at = now.clone();
@@ -203,8 +205,9 @@ pub fn mark_failed(
task_id: &str,
error: String,
) -> Result<(), String> {
+ let task_id = task_id.to_owned();
let updated = update_session(store, subagent_session_id, |session, now| {
- session.current_task_id = Some(task_id.to_string());
+ session.current_task_id = Some(task_id.clone());
session.status = DurableSubagentStatus::Failed;
session.latest_error = Some(error.clone());
session.updated_at = now.clone();
@@ -264,7 +267,7 @@ fn update_session<F>(
update: F,
) -> Result<bool, String>
where
- F: FnMut(&mut DurableSubagentSession, String) + Send,
+ F: FnMut(&mut DurableSubagentSession, String) + Send + 'static,
{
let _guard = store_write_lock()
.lock()
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store.rs
index d573105fb6..2a80f78818 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store.rs
@@ -63,7 +63,7 @@ impl SubagentSessionStore {
update: F,
) -> Result<Option<DurableSubagentSession>, String>
where
- F: FnMut(&mut DurableSubagentSession, String) + Send,
+ F: FnMut(&mut DurableSubagentSession, String) + Send + 'static,
{
let docs = super::store_documents::current(&self.workspace_dir)
.map_err(|err| format!("{err:#}"))?;
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents.rs
index 7447879fd9..301b0d36f5 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents.rs
@@ -208,7 +208,7 @@ impl Docs {
mut update: F,
) -> Result<Option<DurableSubagentSession>>
where
- F: FnMut(&mut DurableSubagentSession, String) + Send,
+ F: FnMut(&mut DurableSubagentSession, String) + Send + 'static,
{
let id = key_of(subagent_session_id)?;
let updated = self.0.run(|docs| async move {