Skip to content

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

fix(channels): finish delivered progressive replies with their text

Steven Enamakeleb0f2ad7b1b1
diff --git a/crates/openhuman-core/src/channels/bus/delivery.rs b/crates/openhuman-core/src/channels/bus/delivery.rs
index b574e6e3d4..92400c02f0 100644
--- a/crates/openhuman-core/src/channels/bus/delivery.rs
+++ b/crates/openhuman-core/src/channels/bus/delivery.rs
@@ -221,6 +221,10 @@ impl NativeProgressiveReply {
crate::modules::report::malformed_reply("tinychannels");
return Err(ModuleCallError::ModuleFault);
}
+ *self
+ .delivered_text
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner) = Some(text.to_owned());
Ok(result)
}
@@ -255,10 +259,21 @@ impl Drop for NativeProgressiveReply {
};
let object = self.object.clone();
let handle = self.handle.clone();
+ let delivered = self
+ .delivered_text
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner)
+ .clone();
runtime.spawn(async move {
+ // A delivered reply is closed with its own terminal text; a plain
+ // close would make the module announce a cancellation.
+ let command = match delivered {
+ Some(text) => ProgressiveCommand::Finish { handle, text },
+ None => ProgressiveCommand::Close { handle },
+ };
let close = object.call_confidential::<ProgressiveResult>(
methods::EXECUTE_PROGRESSIVE,
- (ProgressiveCommand::Close { handle },),
+ (command,),
);
match tokio::time::timeout(std::time::Duration::from_secs(5), close).await {
Ok(Ok(ProgressiveResult::Closed)) => {}