Skip to content

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

chore: files changed crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs,crates/op

Steven Enamakel780bbe952c49
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
index 9a936aa1b0..adaae71c27 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
@@ -22,11 +22,22 @@ use super::super::host_agent::{self, HostRoute};
use super::approval::{channel_has_approval_surface, try_route_approval_reply};
use super::RuntimeChannelMessage;
+fn channel_inbound_preparation_request(
+ source: tinychannels_bus::module_inbound::ChannelInboundSource,
+) -> tinychannels_bus::module_inbound::PrepareChannelInboundRequest {
+ tinychannels_bus::module_inbound::PrepareChannelInboundRequest {
+ source,
+ namespace: "main".into(),
+ session_policy: Default::default(),
+ preparation_mode: Default::default(),
+ }
+}
+
pub(crate) async fn process_channel_runtime_message(
ctx: Arc<ChannelRuntimeContext>,
runtime_msg: RuntimeChannelMessage,
) {
- use tinychannels_bus::module_inbound::{ChannelInboundSource, PrepareChannelInboundRequest};
+ use tinychannels_bus::module_inbound::ChannelInboundSource;
let RuntimeChannelMessage {
message,
inbound_envelope,
@@ -55,12 +66,7 @@ pub(crate) async fn process_channel_runtime_message(
};
match crate::modules::channel_controller::prepare_inbound(
&crate::channels::context::module_client(&ctx).await,
- PrepareChannelInboundRequest {
- source,
- namespace: "main".into(),
- session_policy: Default::default(),
- preparation_mode: Default::default(),
- },
+ channel_inbound_preparation_request(source),
)
.await
{
@@ -619,3 +625,7 @@ pub(crate) async fn process_channel_runtime_message(
workspace_dir: ctx.workspace_dir.as_ref().clone(),
});
}
+
+#[cfg(test)]
+#[path = "turn_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn_tests.rs
new file mode 100644
index 0000000000..69552cbc3e
--- /dev/null
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn_tests.rs
@@ -0,0 +1,61 @@
+use super::*;
+
+#[tokio::test]
+async fn native_inbound_preparation_preserves_image_envelope_for_typed_turns() {
+ use tinychannels_bus::{
+ channel::{
+ ChannelRef, ContentPart, ConversationKind, ConversationRef, MediaKind, MediaReference,
+ SenderRef,
+ },
+ module_inbound::{ChannelInboundSource, PreparedChannelInbound},
+ };
+
+ let envelope = tinychannels_bus::ChannelInboundEnvelope {
+ channel: ChannelRef {
+ id: "telegram".into(),
+ account_id: Some("work".into()),
+ },
+ message_id: "provider-message-7".into(),
+ conversation: ConversationRef {
+ kind: ConversationKind::Dm,
+ id: "chat-12".into(),
+ thread_id: Some("thread-3".into()),
+ topic_id: Some("topic-4".into()),
+ ..Default::default()
+ },
+ sender: SenderRef {
+ id: "sender-2".into(),
+ ..Default::default()
+ },
+ text: String::new(),
+ parts: vec![ContentPart::Image {
+ media: MediaReference {
+ opaque_id: Some("opaque-module-media".into()),
+ content_type: Some("image/png".into()),
+ size_bytes: Some(64),
+ kind: MediaKind::Image,
+ ..Default::default()
+ },
+ caption: None,
+ alt_text: Some("diagram".into()),
+ }],
+ ..Default::default()
+ };
+
+ let request = channel_inbound_preparation_request(ChannelInboundSource::Envelope {
+ envelope: envelope.clone(),
+ timestamp: 1,
+ });
+ let prepared: PreparedChannelInbound = crate::modules::channel_controller::prepare_inbound(
+ &crate::channels::module_fixture::client().await,
+ request,
+ )
+ .await
+ .expect("native channel preparation must retain typed image input");
+
+ assert_eq!(prepared.envelope.parts, envelope.parts);
+ assert_eq!(prepared.envelope.channel, envelope.channel);
+ assert_eq!(prepared.envelope.conversation, envelope.conversation);
+ assert_eq!(prepared.envelope.message_id, "provider-message-7");
+ assert!(prepared.message.content.is_empty());
+}