Skip to content

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

refactor(relay): reformat outbound event publish and test setup

Steven Enamakel1ead4f3db53d
diff --git a/crates/openhuman-core/src/channels/providers/relay/channel.rs b/crates/openhuman-core/src/channels/providers/relay/channel.rs
index e93b3aa381..237f955b98 100644
--- a/crates/openhuman-core/src/channels/providers/relay/channel.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/channel.rs
@@ -98,28 +98,31 @@ impl RelayChannel {
.lock()
.unwrap_or_else(|e| e.into_inner())
.push(text.to_owned());
- publish_web_channel_event_in(ctx, WebChannelEvent::ChannelOutbound {
- context: crate::web_chat::event_context(
- self.client_id.clone(),
- self.thread_id.clone(),
- self.request_id.clone(),
- ),
- full_response: Some(text.to_owned()),
- structured: Some(json!({
- "kind": CHANNEL_OUTBOUND_EVENT,
- "channel": self.channel,
- "chat_id": conversation.id,
- "thread_ts": conversation.thread_id,
- "reply_to_message_id": self.reply_to,
- "turn_id": turn_id,
- "sequence": sequence,
- "segment_index": segment_index,
- "idempotency_key": idempotency_key,
- "channel_ref": channel,
- "conversation_ref": conversation,
- "parts": parts,
- })),
- });
+ publish_web_channel_event_in(
+ ctx,
+ WebChannelEvent::ChannelOutbound {
+ context: crate::web_chat::event_context(
+ self.client_id.clone(),
+ self.thread_id.clone(),
+ self.request_id.clone(),
+ ),
+ full_response: Some(text.to_owned()),
+ structured: Some(json!({
+ "kind": CHANNEL_OUTBOUND_EVENT,
+ "channel": self.channel,
+ "chat_id": conversation.id,
+ "thread_ts": conversation.thread_id,
+ "reply_to_message_id": self.reply_to,
+ "turn_id": turn_id,
+ "sequence": sequence,
+ "segment_index": segment_index,
+ "idempotency_key": idempotency_key,
+ "channel_ref": channel,
+ "conversation_ref": conversation,
+ "parts": parts,
+ })),
+ },
+ );
}
}
diff --git a/crates/openhuman-core/src/channels/runtime/startup/module_providers_tests.rs b/crates/openhuman-core/src/channels/runtime/startup/module_providers_tests.rs
index b495100560..1bda9a3044 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/module_providers_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/module_providers_tests.rs
@@ -287,11 +287,10 @@ async fn compiled_module_hosted_progressive_callback_is_scoped_and_typed() {
};
let mut web_events = crate::web_chat::subscribe_web_channel_events();
let config = Config::default();
- let ctx = DispatchCtx::new(CoreContext::for_test(DomainSet::full(), None).derive_with(
- ContextOverlay::new(config.clone(), DomainSet::kernel(), ToolGroups::none())
- .session_agent("relay-agent")
- .session_profile("relay-profile"),
- ));
+ let mut overlay = ContextOverlay::new(config.clone(), DomainSet::kernel(), ToolGroups::none())
+ .session_agent("relay-agent");
+ overlay.profile = Some("relay-profile".into());
+ let ctx = DispatchCtx::new(CoreContext::for_test(DomainSet::full(), None).derive_with(overlay));
let projection = Arc::new(
crate::web_chat::Surface::new(
&ctx,
@@ -379,9 +378,7 @@ async fn compiled_module_hosted_progressive_callback_is_scoped_and_typed() {
}
match event.event_name() {
"chat_done" => projected = Some(event),
- crate::channels::providers::relay::CHANNEL_OUTBOUND_EVENT => {
- terminal = Some(event)
- }
+ crate::channels::providers::relay::CHANNEL_OUTBOUND_EVENT => terminal = Some(event),
_ => panic!("unexpected relayed output event: {}", event.event_name()),
}
}
@@ -441,11 +438,10 @@ async fn hosted_target_projects_to_the_canonical_thread_and_keeps_one_gateway_te
..Default::default()
};
let config = Config::default();
- let ctx = DispatchCtx::new(CoreContext::for_test(DomainSet::full(), None).derive_with(
- ContextOverlay::new(config.clone(), DomainSet::kernel(), ToolGroups::none())
- .session_agent("relay-target-agent")
- .session_profile("relay-target-profile"),
- ));
+ let mut overlay = ContextOverlay::new(config.clone(), DomainSet::kernel(), ToolGroups::none())
+ .session_agent("relay-target-agent");
+ overlay.profile = Some("relay-target-profile".into());
+ let ctx = DispatchCtx::new(CoreContext::for_test(DomainSet::full(), None).derive_with(overlay));
let target = crate::channels::runtime::dispatch::hosted_relay_target(
&ctx,
&config,