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(flows): thread dispatch context through flow streaming
Steven Enamakel94f79e232146
diff --git a/crates/openhuman-core/src/agent/orchestration/background_delivery.rs b/crates/openhuman-core/src/agent/orchestration/background_delivery.rsindex 61c26c5666..cefaedb174 100644--- a/crates/openhuman-core/src/agent/orchestration/background_delivery.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_delivery.rs@@ -366,12 +366,15 @@ async fn try_deliver(thread_id: String, fence: DrainFence) {};let router = background_completions::router_for_workspace(&workspace_dir);let turn_workspace = workspace_dir.clone();+ // A drain is event-driven and carries no context of its own.+ let ctx = crate::core::runtime::DispatchCtx::host_default();let retry_after = try_deliver_with(thread_id.clone(),router,move |thread_id, notice| {let workspace_dir = turn_workspace.clone();- async move { run_system_turn_on_thread(workspace_dir, thread_id, notice).await }+ let ctx = ctx.clone();+ async move { run_system_turn_on_thread(&ctx, workspace_dir, thread_id, notice).await }},move |thread_id, notice| async move {persist_undelivered(workspace_dir, thread_id, notice).await@@ -630,12 +633,14 @@ impl Drop for DeliverySlot {/// later cold-boot resume would prefer — which is how a restart used to drop/// every turn before the delivery notice.async fn run_system_turn_on_thread(+ ctx: &crate::core::runtime::DispatchCtx,workspace_dir: PathBuf,thread_id: String,prompt: String,) -> Result<String, String> {let run_id = format!("bgdeliver-{}", uuid::Uuid::new_v4());let result = crate::web_chat::run_system_turn_on_thread(+ ctx,&thread_id,&run_id,&prompt,diff --git a/crates/openhuman-core/src/flows/ops/builder.rs b/crates/openhuman-core/src/flows/ops/builder.rsindex 7c3acde563..ae7284a018 100644--- a/crates/openhuman-core/src/flows/ops/builder.rs+++ b/crates/openhuman-core/src/flows/ops/builder.rs@@ -134,7 +134,7 @@ pub(crate) async fn flows_build_with_extra_hidden_tools(// `propose_workflow` tool result the frontend renders as a proposal card.// Best-effort — with no target the run stays headless (CLI / tests).if let Some(target) = &stream {- attach_flow_progress_bridge(&mut agent, target, "flows_build", config);+ attach_flow_progress_bridge(ctx, &mut agent, target, "flows_build", config);}// Run to completion, bounded by a wall-clock timeout. PR3diff --git a/crates/openhuman-core/src/flows/ops/discovery.rs b/crates/openhuman-core/src/flows/ops/discovery.rsindex 15a1bb6a06..00d5d6c988 100644--- a/crates/openhuman-core/src/flows/ops/discovery.rs+++ b/crates/openhuman-core/src/flows/ops/discovery.rs@@ -66,7 +66,7 @@ pub async fn flows_discover(// an interactive turn (see `FlowStreamTarget`). Best-effort — with no target// the run stays headless, exactly as before.if let Some(target) = &stream {- attach_flow_progress_bridge(&mut agent, target, "flows_discover", config);+ attach_flow_progress_bridge(ctx, &mut agent, target, "flows_discover", config);agent.set_thread_id(Some(target.thread_id.as_str()));}diff --git a/crates/openhuman-core/src/flows/ops/streaming.rs b/crates/openhuman-core/src/flows/ops/streaming.rsindex cdcbcbb7ef..e0a62951a5 100644--- a/crates/openhuman-core/src/flows/ops/streaming.rs+++ b/crates/openhuman-core/src/flows/ops/streaming.rs@@ -56,6 +56,7 @@ impl FlowStreamTarget {/// (turn end). `source` is a short trace-attribution label (e.g./// `"flows_build"`).pub(super) fn attach_flow_progress_bridge(+ ctx: &DispatchCtx,agent: &mut crate::agent::OpenHumanSessionHost,target: &FlowStreamTarget,source: &str,@@ -81,6 +82,7 @@ pub(super) fn attach_flow_progress_bridge(..Default::default()},config.clone(),+ ctx.clone(),);}@@ -100,6 +102,7 @@ pub(super) async fn finalize_flow_stream(match result {Ok(text) => {crate::web_chat::presentation::deliver_response(+ ctx,"system",&target.thread_id,&target.request_id,