Skip to content

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

refactor(subagent_sessions): return updated session from store update

Steven Enamakel530cdd6d0d2c
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 62d83c2db7..8f86640f13 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rs
@@ -243,7 +243,9 @@ where
let _guard = store_write_lock()
.lock()
.map_err(|_| "subagent session store lock poisoned".to_string())?;
- store.update_session(subagent_session_id, update)
+ store
+ .update_session(subagent_session_id, update)
+ .map(|updated| updated.is_some())
}
fn store_write_lock() -> &'static Mutex<()> {
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 24c9dfdad8..d573105fb6 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store.rs
@@ -61,7 +61,7 @@ impl SubagentSessionStore {
&self,
subagent_session_id: &str,
update: F,
- ) -> Result<bool, String>
+ ) -> Result<Option<DurableSubagentSession>, String>
where
F: FnMut(&mut DurableSubagentSession, String) + Send,
{
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 0da9efe196..3db23a2feb 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
@@ -206,14 +206,14 @@ impl Docs {
&self,
subagent_session_id: &str,
mut update: F,
- ) -> Result<bool>
+ ) -> Result<Option<DurableSubagentSession>>
where
F: FnMut(&mut DurableSubagentSession, String) + Send,
{
let id = key_of(subagent_session_id)?;
self.0.run(|docs| async move {
let repo = tinystoragedrivers::Repo::<Value>::new(&docs, SESSIONS)?;
- repo.update(&id, move |current| {
+ let updated = repo.update(&id, move |current| {
let Some(current) = current else {
return Ok(None);
};
@@ -222,8 +222,13 @@ impl Docs {
update(&mut session, chrono::Utc::now().to_rfc3339());
Ok(Some(serde_json::to_value(StoredSession::from(&session))?))
})
- .await
- .map(|updated| updated.is_some())
+ .await?;
+ updated
+ .map(|(stored, _)| {
+ serde_json::from_value::<StoredSession>(stored)
+ .map(DurableSubagentSession::from)
+ })
+ .transpose()
})
}