The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(channels): route host agent turns through the bus
Steven Enamakel490be37b347e
diff --git a/crates/openhuman-core/src/channels/host/adapters.rs b/crates/openhuman-core/src/channels/host/adapters.rsindex b050d70e85..35bbf01ad5 100644--- a/crates/openhuman-core/src/channels/host/adapters.rs+++ b/crates/openhuman-core/src/channels/host/adapters.rs@@ -209,7 +209,7 @@ impl ConversationStore for ConversationHistoryStore {session_key: &str,limit: usize,) -> anyhow::Result<Vec<ConversationMessage>> {- let ctx = DispatchCtx::ambient();+ let ctx = DispatchCtx::host_default();let messages = crate::threads::store::get_messages(&ctx,self.workspace_dir.clone(),@@ -228,7 +228,7 @@ impl ConversationStore for ConversationHistoryStore {}async fn append(&self, session_key: &str, message: ConversationMessage) -> anyhow::Result<()> {- let ctx = DispatchCtx::ambient();+ let ctx = DispatchCtx::host_default();let now = chrono::Utc::now().to_rfc3339();// `append_message` requires the thread to exist; create-or-noop first.crate::threads::store::ensure_thread(diff --git a/crates/openhuman-core/src/channels/routes.rs b/crates/openhuman-core/src/channels/routes.rsindex 416d69a919..122e8ae6d3 100644--- a/crates/openhuman-core/src/channels/routes.rs+++ b/crates/openhuman-core/src/channels/routes.rs@@ -107,11 +107,11 @@ impl RouteCallbacks {) -> tinybus::Result<tinychannels_bus::ChannelBackendResult> {match request {tinychannels_bus::ChannelBackendRequest::RemoteControl(request) => {- // The captured context is the carrier; without one the caller's- // own ambient context is what the handlers read before.+ // The captured context is the carrier; without one the host's+ // default context (none in SaaS, which fails closed).let dispatch_ctx = match &self.core_context {Some(core) => crate::core::runtime::DispatchCtx::new(Arc::clone(core)),- None => crate::core::runtime::DispatchCtx::ambient(),+ None => crate::core::runtime::DispatchCtx::host_default(),};let dispatch = async {tokio::select! {diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rsindex fb15cf1809..a79993ecad 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs@@ -54,8 +54,7 @@ pub(crate) fn bound_agent_id<'a>(config: &'a Config, channel: &str) -> Option<&'/// Resolve `channel`'s binding against the installed host agents.pub(crate) fn route(ctx: &ChannelRuntimeContext, channel: &str) -> HostRoute {- // Transitional (#7801): the channel runtime context carries no core yet.- let dispatch = DispatchCtx::ambient();+ let dispatch = ctx.dispatch_ctx();if let Some(capabilities) =crate::profiles::capabilities::ProfileCapabilities::in_ctx(&dispatch){diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/bus_turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/bus_turn.rsindex eedf8ec15e..c25b616558 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/bus_turn.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/bus_turn.rs@@ -59,7 +59,7 @@ pub(super) async fn dispatch_bus_turn(// `config`) stay on an injected model source.turn_model_source: match &ctx.config {Some(cfg) => crate::agent::tinyagents::TurnModelSource::new_crate_native_from_string(- &crate::core::runtime::DispatchCtx::ambient(),+ &ctx.dispatch_ctx(),"chat",route.provider.clone(),cfg.clone(),diff --git a/crates/openhuman-core/src/channels/runtime/startup/callback.rs b/crates/openhuman-core/src/channels/runtime/startup/callback.rsindex 8295438425..9848bb2238 100644--- a/crates/openhuman-core/src/channels/runtime/startup/callback.rs+++ b/crates/openhuman-core/src/channels/runtime/startup/callback.rs@@ -159,11 +159,11 @@ impl ChannelHostCallbacks {let context = self.context()?;let tenant = &self.tenant;let cancellation = &self.cancellation;- // The captured context is the carrier; without one the caller's- // own ambient context is what the handlers read before.+ // The captured context is the carrier; without one the host's+ // default context (none in SaaS, which fails closed).let dispatch_ctx = match &self.core_context {Some(core) => crate::core::runtime::DispatchCtx::new(Arc::clone(core)),- None => crate::core::runtime::DispatchCtx::ambient(),+ None => crate::core::runtime::DispatchCtx::host_default(),};let dispatch = async {tokio::select! {diff --git a/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs b/crates/openhuman-core/src/channels/runtime/startup/start_channels.rsindex 4c72d4bfc4..5f1343e8af 100644--- a/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs+++ b/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs@@ -27,6 +27,9 @@ async fn start_channels_inner(mut config: Config, session: CancellationToken) ->if session.is_cancelled() {return Ok(());}+ // The listener runs for the host's own tenant (none in SaaS, where hosted+ // channels go through the relay under their profile's context).+ let dispatch = crate::core::runtime::DispatchCtx::host_default();// Initialize the global event bus singleton and register the tracing// subscriber for debug logging of all domain events.crate::core::bus::init().await.expect("bus init");@@ -120,7 +123,7 @@ async fn start_channels_inner(mut config: Config, session: CancellationToken) ->// user-configured `[agent].agent_timeout_secs` (#5027).// Model, tools and the identity-refreshing system prompt (`turn_parts`),// shared with the hosted-channel relay.- let parts = build_channel_turn_parts(&config, &security, PromptToolDescs::Fixed)?;+ let parts = build_channel_turn_parts(&dispatch, &config, &security, PromptToolDescs::Fixed)?;let model = parts.model.clone();let workspace = config.workspace_dir.clone();let skills = parts.skills.clone();@@ -264,6 +267,7 @@ async fn start_channels_inner(mut config: Config, session: CancellationToken) ->println!(" 🚦 In-flight message limit: {max_in_flight_messages}");let runtime_ctx = Arc::new(runtime_context(+ &dispatch,&config,parts,Arc::clone(&channels_by_name),