Skip to content

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

feat(orchestration): implement DeliveryFence for DrainFence

Steven Enamakel6e99b90acc5d
diff --git a/crates/openhuman-core/src/agent/orchestration/delivery_drain.rs b/crates/openhuman-core/src/agent/orchestration/delivery_drain.rs
index 2ed4d042db..310f563404 100644
--- a/crates/openhuman-core/src/agent/orchestration/delivery_drain.rs
+++ b/crates/openhuman-core/src/agent/orchestration/delivery_drain.rs
@@ -16,10 +16,12 @@
use crate::core::runtime::DispatchCtx;
use std::future::Future;
+use std::pin::Pin;
use std::sync::Arc;
use std::time::Duration;
use crate::storage::fence::LeaseFence;
+use tinyagents_tasks::DeliveryFence;
use super::busy_guard::is_busy;
@@ -77,6 +79,19 @@ impl DrainFence {
}
}
+impl DeliveryFence for DrainFence {
+ fn admitted(&self) -> bool {
+ self.admits()
+ }
+
+ fn lost(&self) -> Pin<Box<dyn Future<Output = ()> + Send + '_>> {
+ match &self.0 {
+ Some(fence) => Box::pin(async move { fence.fenced().await }),
+ None => Box::pin(std::future::pending()),
+ }
+ }
+}
+
/// How a drain ended.
#[derive(Debug, PartialEq, Eq)]
pub(super) enum DrainOutcome {