Skip to content

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

chore(channels): reindent dispatch processor and delivery code

Steven Enamakel3c49c37e495c
diff --git a/crates/openhuman-core/src/channels/bus/delivery.rs b/crates/openhuman-core/src/channels/bus/delivery.rs
index 2e0c943131..3ffd7d6da0 100644
--- a/crates/openhuman-core/src/channels/bus/delivery.rs
+++ b/crates/openhuman-core/src/channels/bus/delivery.rs
@@ -220,10 +220,7 @@ impl NativeProgressiveReply {
}
/// Deliver the canonical final event and return every receipt/failure fact.
- pub(crate) async fn finish(
- &self,
- text: &str,
- ) -> Result<ProgressiveResult, ModuleCallError> {
+ pub(crate) async fn finish(&self, text: &str) -> Result<ProgressiveResult, ModuleCallError> {
let result: ProgressiveResult = self
.object
.call_confidential(
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive.rs
index a21d9400e2..b77997b66b 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive.rs
@@ -115,7 +115,9 @@ fn delivery_succeeded(result: &tinychannels_bus::module_progressive::Progressive
}
}
-fn delivery_outcome_count(result: &tinychannels_bus::module_progressive::ProgressiveResult) -> usize {
+fn delivery_outcome_count(
+ result: &tinychannels_bus::module_progressive::ProgressiveResult,
+) -> usize {
use tinychannels_bus::module_progressive::ProgressiveResult;
match result {
ProgressiveResult::DeliveryOutcome { .. } => 1,
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 caf5f6d557..09e70d99ac 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
@@ -277,8 +277,8 @@ pub(crate) async fn process_channel_runtime_message(
// Determine if this channel supports streaming draft updates
let use_streaming = native_reply.is_none()
&& target_channel
- .as_ref()
- .is_some_and(|ch| ch.supports_draft_updates());
+ .as_ref()
+ .is_some_and(|ch| ch.supports_draft_updates());
// Set up streaming channel if supported
let (progress_tx, progress_rx) = if native_reply.is_some() || use_streaming {
@@ -312,9 +312,8 @@ pub(crate) async fn process_channel_runtime_message(
// Spawn a task to forward streaming progress to draft updates
let draft_updater = if let Some(reply) = native_reply.clone() {
- progress_rx.map(|rx| {
- AbortOnDropHandle::new(super::progressive::spawn_native_progress(rx, reply))
- })
+ progress_rx
+ .map(|rx| AbortOnDropHandle::new(super::progressive::spawn_native_progress(rx, reply)))
} else if let (Some(mut rx), Some(draft_id_ref), Some(channel_ref)) = (
progress_rx,
draft_message_id.as_deref(),
@@ -542,38 +541,39 @@ pub(crate) async fn process_channel_runtime_message(
started_at.elapsed().as_millis(),
truncate_with_ellipsis(&response_text, REPLY_LOG_TRUNCATE_CHARS)
);
- let delivered = super::progressive::finish_native_reply(&native_reply, &response_text).await;
+ let delivered =
+ super::progressive::finish_native_reply(&native_reply, &response_text).await;
if native_reply.is_none() {
- if let Some(channel) = target_channel.as_ref() {
- if let Some(ref draft_id) = draft_message_id {
- if let Err(e) = channel
- .finalize_draft(
- &msg.reply_target,
- draft_id,
- &response_text,
- msg.thread_ts.as_deref(),
+ if let Some(channel) = target_channel.as_ref() {
+ if let Some(ref draft_id) = draft_message_id {
+ if let Err(e) = channel
+ .finalize_draft(
+ &msg.reply_target,
+ draft_id,
+ &response_text,
+ msg.thread_ts.as_deref(),
+ )
+ .await
+ {
+ tracing::warn!("Failed to finalize draft: {e}; sending as new message");
+ let _ = channel
+ .send_with_outbound_intent(
+ &SendMessage::new(&response_text, &msg.reply_target)
+ .in_thread(msg.thread_ts.clone()),
+ )
+ .await;
+ }
+ } else if let Err(e) = channel
+ .send_with_outbound_intent(
+ &SendMessage::new(&response_text, &msg.reply_target)
+ .in_thread(msg.thread_ts.clone()),
)
.await
{
- tracing::warn!("Failed to finalize draft: {e}; sending as new message");
- let _ = channel
- .send_with_outbound_intent(
- &SendMessage::new(&response_text, &msg.reply_target)
- .in_thread(msg.thread_ts.clone()),
- )
- .await;
+ eprintln!(" ❌ Failed to reply on {}: {e}", channel.name());
}
- } else if let Err(e) = channel
- .send_with_outbound_intent(
- &SendMessage::new(&response_text, &msg.reply_target)
- .in_thread(msg.thread_ts.clone()),
- )
- .await
- {
- eprintln!(" ❌ Failed to reply on {}: {e}", channel.name());
}
}
- }
(delivered, response_text, resolved_provider, resolved_model)
}
Ok(Err(e)) => {
@@ -588,26 +588,26 @@ pub(crate) async fn process_channel_runtime_message(
);
let _ = super::progressive::finish_native_reply(&native_reply, error_text).await;
if native_reply.is_none() {
- if let Some(channel) = target_channel.as_ref() {
- if let Some(ref draft_id) = draft_message_id {
- let _ = channel
- .finalize_draft(
- &msg.reply_target,
- draft_id,
- error_text,
- msg.thread_ts.as_deref(),
- )
- .await;
- } else {
- let _ = channel
- .send_with_outbound_intent(
- &SendMessage::new(error_text, &msg.reply_target)
- .in_thread(msg.thread_ts.clone()),
- )
- .await;
+ if let Some(channel) = target_channel.as_ref() {
+ if let Some(ref draft_id) = draft_message_id {
+ let _ = channel
+ .finalize_draft(
+ &msg.reply_target,
+ draft_id,
+ error_text,
+ msg.thread_ts.as_deref(),
+ )
+ .await;
+ } else {
+ let _ = channel
+ .send_with_outbound_intent(
+ &SendMessage::new(error_text, &msg.reply_target)
+ .in_thread(msg.thread_ts.clone()),
+ )
+ .await;
+ }
}
}
- }
BUS.publish(DomainEvent::ChannelMessageProcessed {
channel: msg.channel.clone(),
@@ -680,26 +680,26 @@ pub(crate) async fn process_channel_runtime_message(
}
let _ = super::progressive::finish_native_reply(&native_reply, &error_response).await;
if native_reply.is_none() {
- if let Some(channel) = target_channel.as_ref() {
- if let Some(ref draft_id) = draft_message_id {
- let _ = channel
- .finalize_draft(
- &msg.reply_target,
- draft_id,
- &error_response,
- msg.thread_ts.as_deref(),
- )
- .await;
- } else {
- let _ = channel
- .send_with_outbound_intent(
- &SendMessage::new(&error_response, &msg.reply_target)
- .in_thread(msg.thread_ts.clone()),
- )
- .await;
+ if let Some(channel) = target_channel.as_ref() {
+ if let Some(ref draft_id) = draft_message_id {
+ let _ = channel
+ .finalize_draft(
+ &msg.reply_target,
+ draft_id,
+ &error_response,
+ msg.thread_ts.as_deref(),
+ )
+ .await;
+ } else {
+ let _ = channel
+ .send_with_outbound_intent(
+ &SendMessage::new(&error_response, &msg.reply_target)
+ .in_thread(msg.thread_ts.clone()),
+ )
+ .await;
+ }
}
}
- }
(
false,
error_response,
@@ -727,26 +727,26 @@ pub(crate) async fn process_channel_runtime_message(
"⚠️ Request timed out while waiting for the model. Please try again.".to_string();
let _ = super::progressive::finish_native_reply(&native_reply, &error_text).await;
if native_reply.is_none() {
- if let Some(channel) = target_channel.as_ref() {
- if let Some(ref draft_id) = draft_message_id {
- let _ = channel
- .finalize_draft(
- &msg.reply_target,
- draft_id,
- &error_text,
- msg.thread_ts.as_deref(),
- )
- .await;
- } else {
- let _ = channel
- .send_with_outbound_intent(
- &SendMessage::new(&error_text, &msg.reply_target)
- .in_thread(msg.thread_ts.clone()),
- )
- .await;
+ if let Some(channel) = target_channel.as_ref() {
+ if let Some(ref draft_id) = draft_message_id {
+ let _ = channel
+ .finalize_draft(
+ &msg.reply_target,
+ draft_id,
+ &error_text,
+ msg.thread_ts.as_deref(),
+ )
+ .await;
+ } else {
+ let _ = channel
+ .send_with_outbound_intent(
+ &SendMessage::new(&error_text, &msg.reply_target)
+ .in_thread(msg.thread_ts.clone()),
+ )
+ .await;
+ }
}
}
- }
(
false,
error_text,