Skip to content

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

feat(voice): add realtime harness agent and turn handler

Steven Enamakel6f440fa8ebc1
diff --git a/crates/openhuman-core/src/voice/realtime_harness/agent.rs b/crates/openhuman-core/src/voice/realtime_harness/agent.rs
index 37bc2c519d..dc3d876613 100644
--- a/crates/openhuman-core/src/voice/realtime_harness/agent.rs
+++ b/crates/openhuman-core/src/voice/realtime_harness/agent.rs
@@ -70,12 +70,13 @@ const VOICE_MODEL: &str = "hint:chat";
/// channel closes. Runs entirely on the background task, so the ack deadline in
/// the caller covers both the build and the model round-trips.
pub(super) async fn run_voice_turn(
+ ctx: &crate::core::runtime::DispatchCtx,
correlation_id: &str,
messages: &[Value],
prompt: &str,
progress_tx: tokio::sync::mpsc::Sender<AgentProgress>,
) -> Result<String, String> {
- let mut agent = build_voice_agent(correlation_id, messages, prompt).await?;
+ let mut agent = build_voice_agent(ctx, correlation_id, messages, prompt).await?;
// Attach the streaming sink before the turn: its presence switches the harness
// onto the true per-token streaming path, and each `AgentProgress::TextDelta`
@@ -93,11 +94,12 @@ pub(super) async fn run_voice_turn(
/// Construct the per-turn voice orchestrator: load config, pin the fast voice
/// model, isolate the transcript namespace, and seed the relayed history.
async fn build_voice_agent(
+ ctx: &crate::core::runtime::DispatchCtx,
correlation_id: &str,
messages: &[Value],
prompt: &str,
) -> Result<OpenHumanSessionHost, String> {
- let config = crate::config::ops::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let mut agent = OpenHumanSessionHost::from_config_for_agent(&config, "orchestrator")
.map_err(|e| format!("orchestrator build failed: {e}"))?;
agent.set_event_context(format!("voice_{correlation_id}"), "voice_agent");
diff --git a/crates/openhuman-core/src/voice/realtime_harness/turn_handler.rs b/crates/openhuman-core/src/voice/realtime_harness/turn_handler.rs
index 96f1d80f4d..7c05eeb495 100644
--- a/crates/openhuman-core/src/voice/realtime_harness/turn_handler.rs
+++ b/crates/openhuman-core/src/voice/realtime_harness/turn_handler.rs
@@ -132,7 +132,11 @@ impl Drop for InFlightGuard {
/// background and delivers its answer into the user's in-app chat. Never panics —
/// every failure path emits `voice:harness:error` (or a clean `done`) so the
/// backend relay ends the turn cleanly.
-pub async fn handle_voice_harness_turn(correlation_id: String, messages: Vec<Value>) {
+pub async fn handle_voice_harness_turn(
+ ctx: crate::core::runtime::DispatchCtx,
+ correlation_id: String,
+ messages: Vec<Value>,
+) {
let prompt = extract_prompt(&messages);
if prompt.trim().is_empty() {
emit_error(&correlation_id, "no user message in the relayed turn").await;
@@ -232,7 +236,7 @@ pub async fn handle_voice_harness_turn(correlation_id: String, messages: Vec<Val
return;
}
};
- let outcome = run_voice_turn(&turn_cid, &turn_messages, &turn_prompt, progress_tx).await;
+ let outcome = run_voice_turn(&ctx, &turn_cid, &turn_messages, &turn_prompt, progress_tx).await;
// Hand the result to the foreground. If it already deferred (dropped the
// receiver at the ack deadline), the send fails and we deliver the reply
// into the user's chat instead.