Skip to content

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

feat(channels): close native progressive replies on drop

Steven Enamakelb4dccb14bf7e
diff --git a/crates/openhuman-core/src/channels/bus/delivery.rs b/crates/openhuman-core/src/channels/bus/delivery.rs
index 61e938ada2..2e0c943131 100644
--- a/crates/openhuman-core/src/channels/bus/delivery.rs
+++ b/crates/openhuman-core/src/channels/bus/delivery.rs
@@ -272,6 +272,29 @@ impl NativeProgressiveReply {
}
}
+impl Drop for NativeProgressiveReply {
+ fn drop(&mut self) {
+ let Ok(runtime) = tokio::runtime::Handle::try_current() else {
+ return;
+ };
+ let object = self.object.clone();
+ let handle = self.handle.clone();
+ runtime.spawn(async move {
+ let close = object.call_confidential::<ProgressiveResult>(
+ methods::EXECUTE_PROGRESSIVE,
+ (ProgressiveCommand::Close { handle },),
+ );
+ match tokio::time::timeout(std::time::Duration::from_secs(5), close).await {
+ Ok(Ok(ProgressiveResult::Closed)) => {}
+ Ok(Ok(_)) => crate::modules::report::malformed_reply("tinychannels"),
+ Ok(Err(_)) | Err(_) => {
+ tracing::debug!("[channels] native progressive cleanup did not complete")
+ }
+ }
+ });
+ }
+}
+
impl ModuleProgressiveReply {
pub(super) async fn open(
config: crate::config::Config,
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive_tests.rs
index 81c7d8256e..37405d422e 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive_tests.rs
@@ -78,8 +78,11 @@ fn progressive_delivery_status_rejects_partial_or_unsupported_terminal_results()
assert!(!delivery_succeeded(&partial));
let unsupported = ProgressiveResult::DeliveryUnsupported {
- parts: vec![tinychannels_bus::channel::OutboundContentPart::Text {
- text: "retained content".into(),
+ parts: vec![tinychannels_bus::channel::OutboundContentPart::Content {
+ part: tinychannels_bus::channel::ContentPart::Text {
+ text: "retained content".into(),
+ markdown_dialect: None,
+ },
}],
};
assert!(!delivery_succeeded(&unsupported));