Skip to content

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

feat(channels): start channel runtimes during startup

Steven Enamakelccef4382a351
diff --git a/crates/openhuman-core/src/channels/runtime/mod.rs b/crates/openhuman-core/src/channels/runtime/mod.rs
index 65177edf7e..080636faff 100644
--- a/crates/openhuman-core/src/channels/runtime/mod.rs
+++ b/crates/openhuman-core/src/channels/runtime/mod.rs
@@ -8,14 +8,16 @@ mod supervision;
pub use startup::start_channels;
pub(crate) use startup::start_channels_with_session;
pub(crate) use startup::{hydrate_channel_credentials, RuntimeProxyClients};
+// 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 startup::{build_channel_turn_parts, runtime_context, PromptToolDescs};
#[cfg(any(test, debug_assertions))]
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::{
- process_channel_message, run_message_dispatch_loop, RuntimeChannelMessage,
-};
+pub(crate) use dispatch::{run_message_dispatch_loop, RuntimeChannelMessage};
#[cfg(test)]
pub(crate) use supervision::spawn_supervised_listener;
diff --git a/crates/openhuman-core/src/channels/runtime/startup.rs b/crates/openhuman-core/src/channels/runtime/startup.rs
index b7fa05bffd..38a75568e0 100644
--- a/crates/openhuman-core/src/channels/runtime/startup.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup.rs
@@ -5,10 +5,12 @@ mod credentials;
mod prompt;
mod relay;
mod start_channels;
+mod turn_parts;
pub(crate) use credentials::{hydrate_channel_credentials, RuntimeProxyClients};
pub use start_channels::start_channels;
pub(crate) use start_channels::start_channels_with_session;
+pub(crate) use turn_parts::{build_channel_turn_parts, runtime_context, PromptToolDescs};
// Re-exported at module scope (rather than left as private `pub(super)`
// items reached only through their owning submodule) so the `#[path]` test
diff --git a/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs b/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs
index 82e2487f75..2586e84631 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs
@@ -3,26 +3,18 @@
use super::super::dispatch::{run_message_dispatch_loop, RuntimeChannelMessage};
use super::super::supervision::spawn_supervised_listener;
-use super::chat_workload::{resolve_chat_workload, ChatWorkloadResolution};
use super::credentials::{hydrate_channel_credentials, RuntimeProxyClients};
-use super::prompt::format_access_context;
use super::relay::start_relay_runtime;
-use crate::agent::host_runtime;
-use crate::channels::context::{
- effective_channel_message_timeout_secs, ChannelRuntimeContext,
- DEFAULT_CHANNEL_INITIAL_BACKOFF_SECS, DEFAULT_CHANNEL_MAX_BACKOFF_SECS,
-};
-use crate::channels::system_prompt::{ChannelPromptInputs, ChannelSystemPrompt};
+use super::turn_parts::{build_channel_turn_parts, runtime_context, PromptToolDescs};
+use crate::channels::context::{DEFAULT_CHANNEL_INITIAL_BACKOFF_SECS, DEFAULT_CHANNEL_MAX_BACKOFF_SECS};
use crate::channels::traits;
use crate::config::Config;
use crate::core::bus::BUS;
use crate::core::events::DomainEvent;
-use crate::inference::provider;
use crate::security::SecurityPolicy;
-use crate::tools;
use anyhow::Result;
use std::collections::HashMap;
-use std::sync::{Arc, Mutex};
+use std::sync::Arc;
use tinychannels::runtime::compute_max_in_flight_messages;
use tokio_util::task::AbortOnDropHandle;