Skip to content

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

chore: files changed crates/openhuman-rpc/src/server/http/dictation.rs,crates/openhuman-rpc/src/serv

Steven Enamakela3c4f7024797
diff --git a/crates/openhuman-rpc/src/server/http/dictation.rs b/crates/openhuman-rpc/src/server/http/dictation.rs
index 5912ee53fe..b623fda143 100644
--- a/crates/openhuman-rpc/src/server/http/dictation.rs
+++ b/crates/openhuman-rpc/src/server/http/dictation.rs
@@ -30,6 +30,7 @@ pub(super) struct DictationQuery {
/// or wrong credentials are rejected with 401 and the socket is never upgraded.
pub(super) async fn dictation_ws_handler(
headers: axum::http::HeaderMap,
+ ctx: Option<axum::extract::Extension<DispatchCtx>>,
Query(query): Query<DictationQuery>,
ws: WebSocketUpgrade,
) -> Response {
@@ -39,8 +40,11 @@ pub(super) async fn dictation_ws_handler(
return error.into_response();
}
+ // The context the serving middleware attached; the upgraded socket runs on
+ // its own task, so the config is read under it, not the task's.
+ let ctx = ctx.map_or_else(DispatchCtx::unbound, |axum::extract::Extension(ctx)| ctx);
ws.on_upgrade(|socket| async move {
- let config = match crate::core_host::config::rpc::load_config_with_timeout().await {
+ let config = match ctx.load_config().await {
Ok(c) => Arc::new(c),
Err(e) => {
log::error!("[ws] failed to load config for dictation: {e}");
diff --git a/crates/openhuman-rpc/src/server/http/events.rs b/crates/openhuman-rpc/src/server/http/events.rs
index 00fec7e72c..a4a2f5724c 100644
--- a/crates/openhuman-rpc/src/server/http/events.rs
+++ b/crates/openhuman-rpc/src/server/http/events.rs
@@ -178,7 +178,8 @@ pub(super) async fn domain_events_handler(headers: axum::http::HeaderMap) -> Res
}
// Read dashboard config for event stream settings.
- let es_cfg = crate::core_host::config::rpc::load_config_with_timeout()
+ let es_cfg = ctx
+ .load_config()
.await
.map(|c| c.dashboard.event_stream)
.unwrap_or_default();
diff --git a/crates/openhuman-rpc/src/server/http/live_voice.rs b/crates/openhuman-rpc/src/server/http/live_voice.rs
index 11a4754d1a..c291a27098 100644
--- a/crates/openhuman-rpc/src/server/http/live_voice.rs
+++ b/crates/openhuman-rpc/src/server/http/live_voice.rs
@@ -6,14 +6,17 @@
use std::sync::Arc;
-use axum::extract::{Query, WebSocketUpgrade};
+use axum::extract::{Extension, Query, WebSocketUpgrade};
use axum::response::{IntoResponse, Response};
+use crate::core_host::core::runtime::DispatchCtx;
+
use super::dictation::{authorize_dictation_request, DictationQuery};
/// WebSocket upgrade handler for live voice sessions.
pub(super) async fn live_voice_ws_handler(
headers: axum::http::HeaderMap,
+ ctx: Option<Extension<DispatchCtx>>,
Query(query): Query<DictationQuery>,
ws: WebSocketUpgrade,
) -> Response {
@@ -21,16 +24,20 @@ pub(super) async fn live_voice_ws_handler(
if let Err(error) = authorize_dictation_request(&headers, &query) {
return error.into_response();
}
+ // The context the serving middleware attached: the upgraded socket runs on
+ // its own task, so it cannot be read back from the request task. A request
+ // that carries none has no tenant, which fails closed in SaaS.
+ let ctx = ctx.map_or_else(DispatchCtx::unbound, |Extension(ctx)| ctx);
// Agent audio arrives in ~40 ms chunks; keep frames small and unbounded
// in count rather than buffering.
ws.on_upgrade(|socket| async move {
- let config = match crate::core_host::config::rpc::load_config_with_timeout().await {
+ let config = match ctx.load_config().await {
Ok(c) => Arc::new(c),
Err(e) => {
log::error!("[ws] failed to load config for live voice: {e}");
return;
}
};
- crate::core_host::voice::live::ws::handle_live_voice_ws(socket, config).await;
+ crate::core_host::voice::live::ws::handle_live_voice_ws(socket, ctx, config).await;
})
}