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
refactor(voice): carry approval chat context on the run context
Steven Enamakel03cd53c61b24
diff --git a/crates/openhuman-core/src/voice/live/session.rs b/crates/openhuman-core/src/voice/live/session.rsindex e286b14be4..c34887b448 100644--- a/crates/openhuman-core/src/voice/live/session.rs+++ b/crates/openhuman-core/src/voice/live/session.rs@@ -20,7 +20,7 @@ use crate::agent::tinyagents::live_harness::{assemble_live_tool_harness, LIVE_MAuse crate::agent::turn_origin::{with_origin, AgentTurnOrigin};use crate::config::schema::voice_live::is_live_provider;use crate::config::Config;-use crate::security::approval::{ApprovalChatContext, APPROVAL_CHAT_CONTEXT};+use crate::security::approval::{ApprovalChatContext, ApprovalTurnContext};use crate::threads::store::{ConversationMessage, CreateConversationThread};/// The agent a live session borrows its tools from.@@ -176,33 +176,32 @@ pub(crate) async fn start(message_id: format!("voice-live-{session_id}"),history_key: None,};+ let approval = ApprovalChatContext {+ thread_id: thread_id.clone(),+ client_id: request+ .client_id+ .unwrap_or_else(|| format!("voice-live-{session_id}")),+ request_id: None,+ };let mut context = OpenHumanRunContext::new();context.origin = Some(origin.clone());+ // The chat the session's approvals surface in rides the run context, which+ // reaches the gate and every tool the live agent runs.+ context.approval = ApprovalTurnContext::chat(approval);context.thread_id = Some(thread_id.clone());context.workspace = host.live_workspace_descriptor();let run_config =RunConfig::new(format!("voice-live-{session_id}")).with_max_tool_calls(LIVE_MAX_TOOL_CALLS);let ctx = context.into_tinyagents(run_config);- let approval = ApprovalChatContext {- thread_id: thread_id.clone(),- client_id: request- .client_id- .unwrap_or_else(|| format!("voice-live-{session_id}")),- request_id: None,- };- // The approval gate still reads the turn origin and chat context from- // task-locals (an unlabelled call is treated as `Unknown` and denied), so- // the tool worker — a spawned task — must be scoped explicitly. Baselined- // in `agent-runtime-boundary-baseline.json` with the other entry points- // until the gate reads the origin from the run context.+ // The approval gate still reads the turn origin from a task-local (an+ // unlabelled call is treated as `Unknown` and denied), so the tool worker+ // -- a spawned task -- must be scoped explicitly. Baselined in+ // `agent-runtime-boundary-baseline.json` with the other entry points until+ // the gate reads the origin from the run context.let scope: TaskScope = Arc::new(move |task| {let origin = origin.clone();- let approval = approval.clone();- Box::pin(with_origin(- origin,- APPROVAL_CHAT_CONTEXT.scope(approval, task),- ))+ Box::pin(with_origin(origin, task))});let agent = LiveAgent::new(Arc::new(harness), Arc::new(())).with_task_scope(scope);let session = agentdiff --git a/crates/openhuman-core/src/voice/realtime_harness/agent.rs b/crates/openhuman-core/src/voice/realtime_harness/agent.rsindex 8f58b18137..37bc2c519d 100644--- a/crates/openhuman-core/src/voice/realtime_harness/agent.rs+++ b/crates/openhuman-core/src/voice/realtime_harness/agent.rs@@ -131,13 +131,12 @@ async fn run_single_with_timeout(correlation_id: &str,prompt: &str,) -> Result<String, String> {- // Scope the turn with the SAME chat context the web-chat path installs- // (`APPROVAL_CHAT_CONTEXT` plus an explicit agent thread), so approval-surfaced tools+ // Hand the turn the SAME chat context the web-chat path does (an approval+ // context plus an explicit agent thread), so approval-surfaced tools// behave identically on voice. Without it `composio_connect` fails closed// for lack of a routable surface, which the model paraphrases to the user as// a confabulated "reconnect your Gmail" mid email-summary (#5399). See- // VOICE_CHAT_THREAD_ID for the full rationale. Nesting mirrors web chat:- // origin (outer) → approval context → thread id → the agent run.+ // VOICE_CHAT_THREAD_ID for the full rationale.let approval_ctx = crate::security::approval::ApprovalChatContext {thread_id: VOICE_CHAT_THREAD_ID.to_string(),client_id: VOICE_CHAT_CLIENT_ID.to_string(),@@ -145,7 +144,11 @@ async fn run_single_with_timeout(request_id: None,};agent.set_thread_id(Some(VOICE_CHAT_THREAD_ID));- let scoped_run = agent.run_single(prompt);+ let scoped_run = agent.run_single_with_approval(+ prompt,+ None,+ crate::security::approval::ApprovalTurnContext::chat(approval_ctx),+ );let fut = with_origin(AgentTurnOrigin::ExternalChannel {sender_name: None,@@ -155,7 +158,7 @@ async fn run_single_with_timeout(message_id: format!("voice-{correlation_id}"),history_key: None,},- crate::security::approval::APPROVAL_CHAT_CONTEXT.scope(approval_ctx, scoped_run),+ scoped_run,);match tokio::time::timeout(Duration::from_secs(TURN_TIMEOUT_SECS), fut).await {