Skip to content

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

fix(channels): merge captionless media messages into batches

Steven Enamakel01ac2f9d9146
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/inbound_batch.rs b/crates/openhuman-core/src/channels/runtime/dispatch/inbound_batch.rs
index 8fb0503113..ebac3e732d 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/inbound_batch.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/inbound_batch.rs
@@ -33,8 +33,9 @@ impl DebounceItem for QueuedInbound {
let inbound = &self.inbound;
let trimmed = inbound.msg.content.trim_start();
// Imported history and hosted-relay callback targets belong to exactly
- // one message, so such a message always runs as its own batch.
- !trimmed.is_empty()
+ // one message, so such a message always runs as its own batch. A
+ // captionless image or voice note still merges with the text around it.
+ has_substance(inbound)
&& !trimmed.starts_with('/')
&& inbound.imported_history.is_empty()
&& inbound.legacy_history.is_none()
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/inbound_batch_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch/inbound_batch_tests.rs
index a4c70f558d..037dd9fce4 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/inbound_batch_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/inbound_batch_tests.rs
@@ -139,3 +139,15 @@ fn item_traits_classify_media_commands_blanks_and_owned_state() {
"imported history belongs to one message"
);
}
+
+#[test]
+fn a_captionless_typed_part_is_mergeable_but_a_blank_text_is_not() {
+ let mut voice = queued(1, "m1", 1, "");
+ voice.inbound.envelope.parts = vec![ContentPart::Image {
+ media: Default::default(),
+ caption: None,
+ alt_text: None,
+ }];
+ assert!(voice.mergeable(), "an image with no caption still merges");
+ assert!(!queued(1, "m2", 2, " ").mergeable());
+}