Skip to content

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

refactor(channels): route relay turns through the runtime module

Steven Enamakel10ae84d5fa4a
diff --git a/crates/openhuman-core/src/channels/providers/relay/ops.rs b/crates/openhuman-core/src/channels/providers/relay/ops.rs
index c8f74160b1..08f6c3aad0 100644
--- a/crates/openhuman-core/src/channels/providers/relay/ops.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/ops.rs
@@ -216,8 +216,7 @@ pub(crate) async fn run_relay_turn(
request_id = %request_id,
"[channels::relay] dispatching relayed turn"
);
- let mut runtime_message =
- crate::channels::runtime::dispatch::RuntimeChannelMessage::from(message);
+ let mut runtime_message = crate::channels::runtime::RuntimeChannelMessage::from(message);
runtime_message.prepared_inbound = Some(prepared);
super::with_thread(
thread_id.clone(),
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 f73d1cf366..deb22f8511 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
@@ -86,7 +86,7 @@ pub(crate) async fn process_channel_runtime_message(
let msg = prepared.message;
let history_key = prepared.history_key;
let mut envelope = prepared.envelope;
- envelope.delivered_via_upstream_relay = authenticated_relay;
+ envelope.access.delivered_via_upstream_relay = authenticated_relay;
println!(
" 💬 [{}] from {}: {}",
diff --git a/crates/openhuman-core/src/channels/runtime/mod.rs b/crates/openhuman-core/src/channels/runtime/mod.rs
index 17130f4994..330e5566cd 100644
--- a/crates/openhuman-core/src/channels/runtime/mod.rs
+++ b/crates/openhuman-core/src/channels/runtime/mod.rs
@@ -12,7 +12,9 @@ pub use startup::start_channels;
pub(crate) use startup::start_channels_with_session;
// The hosted-channel relay (`channels::providers::relay`) runs one message
// through the same pipeline, with a context built from the caller's config.
-pub(crate) use dispatch::process_channel_message;
+pub(crate) use dispatch::{
+ process_channel_message, process_channel_runtime_message, RuntimeChannelMessage,
+};
pub(crate) use startup::{build_channel_turn_parts, runtime_context, PromptToolDescs};
#[cfg(any(test, debug_assertions))]
@@ -20,6 +22,6 @@ pub mod test_support;
// Re-exported for `channels::tests` only; omit in normal lib builds to avoid unused-import warnings.
#[cfg(test)]
-pub(crate) use dispatch::{run_message_dispatch_loop, RuntimeChannelMessage};
+pub(crate) use dispatch::run_message_dispatch_loop;
#[cfg(test)]
pub(crate) use supervision::spawn_supervised_listener;
diff --git a/crates/openhuman-core/src/channels/runtime/supervision.rs b/crates/openhuman-core/src/channels/runtime/supervision.rs
index 707d40a51b..3ec9ca3cfd 100644
--- a/crates/openhuman-core/src/channels/runtime/supervision.rs
+++ b/crates/openhuman-core/src/channels/runtime/supervision.rs
@@ -42,7 +42,33 @@ impl ListenerObserver for OpenHumanListenerObserver {
}
}
-/// Start a TinyChannels listener with OpenHuman observability attached.
+// Adapt host-owned test doubles to the legacy provider supervisor. Production
+// receives supervision facts from the compiled module instead.
+struct LegacyListenerFixture(Arc<dyn Channel>);
+
+#[async_trait::async_trait]
+impl tinychannels::Channel for LegacyListenerFixture {
+ fn name(&self) -> &str {
+ self.0.name()
+ }
+
+ async fn send(&self, message: &traits::SendMessage) -> anyhow::Result<()> {
+ self.0.send(message).await
+ }
+
+ async fn listen(
+ &self,
+ tx: tokio::sync::mpsc::Sender<traits::ChannelMessage>,
+ ) -> anyhow::Result<()> {
+ self.0.listen(tx).await
+ }
+
+ async fn health_check(&self) -> bool {
+ self.0.health_check().await
+ }
+}
+
+/// Start a legacy listener fixture with OpenHuman observability attached.
pub(crate) fn spawn_supervised_listener(
channel: Arc<dyn Channel>,
tx: tokio::sync::mpsc::Sender<traits::ChannelMessage>,
@@ -51,7 +77,7 @@ pub(crate) fn spawn_supervised_listener(
) -> tokio::task::JoinHandle<()> {
crate::platform::health::bus::register_health_subscriber();
tinychannels::runtime::spawn_supervised_listener(
- channel,
+ Arc::new(LegacyListenerFixture(channel)),
tx,
initial_backoff_secs,
max_backoff_secs,