Skip to content

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

fix(channels): dereference boxed progressive transport request

Steven Enamakel0fe3f7193a4a
diff --git a/crates/openhuman-tinyhumans/src/channels/delivery.rs b/crates/openhuman-tinyhumans/src/channels/delivery.rs
index 50bde14499..4572f25430 100644
--- a/crates/openhuman-tinyhumans/src/channels/delivery.rs
+++ b/crates/openhuman-tinyhumans/src/channels/delivery.rs
@@ -44,7 +44,7 @@ fn transport_context(
conversation: Option<tinychannels_bus::ConversationRef>,
sequence: Option<u64>,
idempotency_key: Option<String>,
- receipt: Option<tinychannels_bus::MessageReceipt>,
+ receipt: Option<tinychannels_bus::channel::MessageReceipt>,
segment_index: Option<u32>,
) -> Map<String, Value> {
let mut context = Map::new();
diff --git a/crates/openhuman-tinyhumans/src/channels/mod.rs b/crates/openhuman-tinyhumans/src/channels/mod.rs
index f8e2c9d26a..3d53e9076a 100644
--- a/crates/openhuman-tinyhumans/src/channels/mod.rs
+++ b/crates/openhuman-tinyhumans/src/channels/mod.rs
@@ -40,7 +40,7 @@ pub(crate) async fn serve(
use ChannelBackendResult as Result;
match request {
Request::ProgressiveTransport(request) => Ok(Result::ProgressiveTransport(
- delivery::execute(&ctx, request).await,
+ delivery::execute(&ctx, *request).await,
)),
Request::SendReaction { channel, reaction } => {
messaging::send_reaction(&ctx.config, &channel, reaction)
diff --git a/crates/openhuman-tinyhumans/src/channels/mod_tests.rs b/crates/openhuman-tinyhumans/src/channels/mod_tests.rs
index b6eb701183..2ce211c02a 100644
--- a/crates/openhuman-tinyhumans/src/channels/mod_tests.rs
+++ b/crates/openhuman-tinyhumans/src/channels/mod_tests.rs
@@ -5,7 +5,7 @@ use tinychannels_bus::module_progressive::{
ProgressiveTransportRequest, ProgressiveTransportResult,
};
use tokio_util::sync::CancellationToken;
-use wiremock::matchers::{method, path};
+use wiremock::matchers::{body_json, method, path};
use wiremock::{Mock, MockServer, ResponseTemplate};
use crate::client::HostedApiError;
@@ -100,6 +100,66 @@ async fn typing_posts_to_the_channel_route_with_the_session_credential() {
}
}
+#[tokio::test]
+async fn progressive_send_forwards_turn_and_delivery_context() {
+ let tmp = tempfile::tempdir().unwrap();
+ let server = MockServer::start().await;
+ Mock::given(method("POST"))
+ .and(path("/channels/telegram/messages"))
+ .and(body_json(json!({
+ "text": "hello",
+ "transportContext": {
+ "turnId": "turn-7",
+ "channelRef": {"id": "telegram", "accountId": "account-2"},
+ "conversation": {
+ "kind": "dm",
+ "id": "chat-3",
+ "scopeId": null,
+ "parentId": null,
+ "threadId": null,
+ "topicId": null
+ },
+ "sequence": 4,
+ "idempotencyKey": "turn-7:reply"
+ }
+ })))
+ .respond_with(
+ ResponseTemplate::new(200)
+ .set_body_json(json!({"success": true, "data": {"id": "message-9"}})),
+ )
+ .mount(&server)
+ .await;
+
+ let config = test_support::signed_in(&tmp, &server.uri());
+ let answer = serve(
+ ctx(config, Some("telegram")),
+ ChannelBackendRequest::ProgressiveTransport(Box::new(
+ ProgressiveTransportRequest::Send {
+ channel: "telegram".into(),
+ turn_id: Some("turn-7".into()),
+ channel_ref: Some(tinychannels_bus::ChannelRef {
+ id: "telegram".into(),
+ account_id: Some("account-2".into()),
+ }),
+ conversation: Some(tinychannels_bus::ConversationRef {
+ kind: tinychannels_bus::ConversationKind::Dm,
+ id: "chat-3".into(),
+ ..Default::default()
+ }),
+ sequence: Some(4),
+ idempotency_key: Some("turn-7:reply".into()),
+ message: json!({"text": "hello"}),
+ },
+ )),
+ )
+ .await
+ .unwrap();
+ assert!(matches!(
+ answer,
+ ChannelBackendResult::ProgressiveTransport(ProgressiveTransportResult::Success(_))
+ ));
+}
+
#[tokio::test]
async fn a_request_for_another_channel_is_refused() {
let tmp = tempfile::tempdir().unwrap();