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 run and resume
Steven Enamakelf00f7bec37e9
diff --git a/crates/openhuman-core/src/flows/builder_host.rs b/crates/openhuman-core/src/flows/builder_host.rsindex 634f6ade36..6c53940d71 100644--- a/crates/openhuman-core/src/flows/builder_host.rs+++ b/crates/openhuman-core/src/flows/builder_host.rs@@ -132,7 +132,9 @@ impl FlowStore for FlowsHost {approve: Vec<String>,reject: Vec<String>,) -> PortResult<Value> {- ops::flows_resume(&self.config, flow_id, run_id, approve, reject)+ // Transitional (#7801): the builder host (`FlowsHost`) carries no context yet.+ let ctx = crate::core::runtime::DispatchCtx::ambient();+ ops::flows_resume(&ctx, &self.config, flow_id, run_id, approve, reject).await.map(|o| o.value)}diff --git a/crates/openhuman-core/src/flows/bus/trigger.rs b/crates/openhuman-core/src/flows/bus/trigger.rsindex bacc3c701b..0f03a9ea29 100644--- a/crates/openhuman-core/src/flows/bus/trigger.rs+++ b/crates/openhuman-core/src/flows/bus/trigger.rs@@ -231,13 +231,14 @@ impl FlowTriggerSubscriber {};let config = self.config_for_scope(ctx);+ let run_ctx = ctx.clone();// Scoped: the run keeps the owner's context the handler entered.ctx.spawn(async move {// Held for the lifetime of the run; released on drop (including// on panic) by `InFlightGuard`.let _guard = guard;tracing::info!(target: "flows", %flow_id, "[flows] trigger fired — starting run");- match crate::flows::ops::flows_run(&config, &flow_id, input, inputs, trigger).await {+ match crate::flows::ops::flows_run(&run_ctx, &config, &flow_id, input, inputs, trigger).await {Ok(_) => {tracing::info!(target: "flows", %flow_id, "[flows] trigger-driven run finished")}diff --git a/crates/openhuman-core/src/flows/schemas_handlers.rs b/crates/openhuman-core/src/flows/schemas_handlers.rsindex f08c03a1b6..15ac092649 100644--- a/crates/openhuman-core/src/flows/schemas_handlers.rs+++ b/crates/openhuman-core/src/flows/schemas_handlers.rs@@ -144,6 +144,7 @@ fn handle_run(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuturelet inputs = read_declared_inputs(¶ms)?;to_json(ops::flows_run(+ &ctx,&config,id.trim(),input,@@ -163,6 +164,7 @@ fn handle_run_detached(ctx: DispatchCtx, params: Map<String, Value>) -> Controlllet inputs = read_declared_inputs(¶ms)?;to_json(ops::flows_run_detached(+ &ctx,&config,id.trim(),input,@@ -220,7 +222,7 @@ fn handle_resume(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFutu.map_err(|e| format!("invalid 'rejections': {e}"))?.unwrap_or_default();to_json(- ops::flows_resume(&config, id.trim(), thread_id.trim(), approvals, rejections).await?,+ ops::flows_resume(&ctx, &config, id.trim(), thread_id.trim(), approvals, rejections).await?,)})}diff --git a/crates/openhuman-core/src/flows/tools.rs b/crates/openhuman-core/src/flows/tools.rsindex cc75939ec8..97bc27fe1a 100644--- a/crates/openhuman-core/src/flows/tools.rs+++ b/crates/openhuman-core/src/flows/tools.rs@@ -261,6 +261,17 @@ impl Tool for RunFlowTool {}async fn execute(&self, args: Value) -> anyhow::Result<ToolResult> {+ self.execute_with_context(args, tinytools::ToolCallOptions::default(), None)+ .await+ }++ async fn execute_with_context(+ &self,+ args: Value,+ _options: tinytools::ToolCallOptions,+ tool_context: Option<&dyn tinytools::ToolRunContext>,+ ) -> anyhow::Result<ToolResult> {+ let ctx = crate::agent::tinyagents::host::run_context::dispatch_ctx_for_tool(tool_context);let flow_id = match args.get("flow_id").and_then(Value::as_str).map(str::trim) {Some(id) if !id.is_empty() => id.to_string(),_ => {@@ -303,6 +314,7 @@ impl Tool for RunFlowTool {// task, and returns `{ run_id, status: "running" }` in well under 120s.// The copilot then polls `get_flow_run(run_id)` to observe completion.match crate::flows::ops::flows_run_detached(+ &ctx,&self.config,&flow_id,input,