Skip to content

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

fix(relay): deliver messages to subscribers when relay ops run

Steven Enamakel58efd9b7eed9
diff --git a/crates/openhuman-core/src/channels/bus/subscriber.rs b/crates/openhuman-core/src/channels/bus/subscriber.rs
index 53e2ffb3dd..11a96fe7aa 100644
--- a/crates/openhuman-core/src/channels/bus/subscriber.rs
+++ b/crates/openhuman-core/src/channels/bus/subscriber.rs
@@ -65,7 +65,9 @@ impl EventHandler<DomainEvent> for ChannelInboundSubscriber {
}
let session = crate::channels::runtime::session::channel_session();
- let config = match crate::config::rpc::load_config_with_timeout().await {
+ // An inbound channel event carries no context of its own.
+ let ctx = crate::core::runtime::DispatchCtx::host_default();
+ let config = match ctx.load_config().await {
Ok(config) => config,
Err(error) => {
tracing::error!("[channel-inbound] failed to load configuration: {error}");
@@ -103,6 +105,7 @@ impl EventHandler<DomainEvent> for ChannelInboundSubscriber {
};
let request_id = match crate::web_chat::start_chat(
+ &ctx,
&client_id,
&thread_id,
message,
diff --git a/crates/openhuman-core/src/channels/providers/relay/ops.rs b/crates/openhuman-core/src/channels/providers/relay/ops.rs
index 7e93f972b7..167b387ecf 100644
--- a/crates/openhuman-core/src/channels/providers/relay/ops.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/ops.rs
@@ -23,12 +23,15 @@ use crate::security::SecurityPolicy;
///
/// A message already recorded on its thread (`message_id`) is acknowledged as
/// a duplicate and runs no turn, so a gateway can retry a delivery.
-pub async fn channel_relay_inbound(params: RelayInboundParams) -> Result<Outcome<Value>, String> {
+pub async fn channel_relay_inbound(
+ ctx: &crate::core::runtime::DispatchCtx,
+ params: RelayInboundParams,
+) -> Result<Outcome<Value>, String> {
params.validate()?;
// In SaaS a relayed message must run as its user: with no tenant scope
// there is no workspace, stream or config it may touch.
let tenant = crate::core::runtime::current_tenant().map_err(|error| error.to_string())?;
- let config = crate::config::rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let identity = crate::modules::channel_controller::prepare_identity(
&crate::modules::client(config.clone()),
tinychannels_bus::module_inbound::PrepareChannelIdentityRequest {
diff --git a/crates/openhuman-core/src/channels/providers/relay/schemas.rs b/crates/openhuman-core/src/channels/providers/relay/schemas.rs
index ed5c812853..2695314c3d 100644
--- a/crates/openhuman-core/src/channels/providers/relay/schemas.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/schemas.rs
@@ -92,11 +92,11 @@ pub fn schemas(function: &str) -> ControllerSchema {
}
}
-fn handle_relay_inbound(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_relay_inbound(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let params: RelayInboundParams = serde_json::from_value(Value::Object(params))
.map_err(|e| format!("invalid params: {e}"))?;
- channel_relay_inbound(params)
+ channel_relay_inbound(&ctx, params)
.await?
.into_cli_compatible_json()
})
diff --git a/crates/openhuman-core/src/threads/schemas/handlers.rs b/crates/openhuman-core/src/threads/schemas/handlers.rs
index 7eab7e50af..693b09b447 100644
--- a/crates/openhuman-core/src/threads/schemas/handlers.rs
+++ b/crates/openhuman-core/src/threads/schemas/handlers.rs
@@ -215,7 +215,7 @@ pub(super) fn handle_search(_ctx: DispatchCtx, params: Map<String, Value>) -> Co
}
pub(super) fn handle_edit_message(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
@@ -224,7 +224,7 @@ pub(super) fn handle_edit_message(
})
}
-pub(super) fn handle_regenerate(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_regenerate(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let p = parse::<ops::RegenerateRequest>(params)?;
to_json(ops::regenerate(&ctx, p).await.map_err(|e| e.to_string())?)