Skip to content

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

refactor(subagent_sessions): simplify parent epoch lookup with and_then

Steven Enamakel2663b044eb1e
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.rs
index 58a2c26e7f..dd93ddbff7 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
@@ -53,8 +53,7 @@ pub(crate) fn parent_epoch_from_sidecar(
Ok(repo
.get(&session_id)
.await?
- .map(|record| record.doc.parent_epoch))
- .flatten()
+ .and_then(|record| record.doc.parent_epoch))
})
.map_err(|error| SubagentError::Persistence(format!("read parent epoch: {error}")))
}
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/tiny_port_tests.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/tiny_port_tests.rs
index 9275f6ad87..19c699e91d 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/tiny_port_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/tiny_port_tests.rs
@@ -75,9 +75,14 @@ async fn driver_store_imports_legacy_rows_without_losing_host_epoch() {
.clone()
});
assert_eq!(
- parent_epoch_from_sidecar(documents, "legacy-session".into()).unwrap(),
+ parent_epoch_from_sidecar(Arc::clone(&documents), "legacy-session".into()).unwrap(),
Some(7)
);
+ import_parent_epoch(Arc::clone(&documents), "legacy-session".into(), None).unwrap();
+ assert_eq!(
+ parent_epoch_from_sidecar(documents, "legacy-session".into()).unwrap(),
+ None
+ );
}
#[tokio::test]