Skip to content

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

feat(flows): add flow execution, resume, and run operations

Steven Enamakel5a7c6db3dfcc
diff --git a/crates/openhuman-core/src/flows/ops/execution.rs b/crates/openhuman-core/src/flows/ops/execution.rs
index 40b41b7bfe..fdad8f9011 100644
--- a/crates/openhuman-core/src/flows/ops/execution.rs
+++ b/crates/openhuman-core/src/flows/ops/execution.rs
@@ -98,6 +98,7 @@ pub(super) async fn export_run_to_langfuse(
#[allow(clippy::too_many_arguments)]
#[inline(never)]
pub(super) fn run_flow_body(
+ ctx: crate::core::runtime::DispatchCtx,
config_arc: Arc<Config>,
flow: Flow,
flow_id: String,
@@ -110,6 +111,7 @@ pub(super) fn run_flow_body(
_run_guard: run_registry::RunGuard,
) -> futures::future::BoxFuture<'static, Result<Outcome<Value>, String>> {
Box::pin(run_flow_body_inner(
+ ctx,
config_arc,
flow,
flow_id,
@@ -125,6 +127,7 @@ pub(super) fn run_flow_body(
#[allow(clippy::too_many_arguments)]
async fn run_flow_body_inner(
+ ctx: crate::core::runtime::DispatchCtx,
config_arc: Arc<Config>,
flow: Flow,
flow_id: String,
@@ -233,6 +236,7 @@ async fn run_flow_body_inner(
run_id: thread_id.clone(),
};
let caps = crate::flows::tinyflows::build_capabilities(
+ &ctx,
config_arc.clone(),
format!("flow:{flow_id}"),
Some(flow_run),
diff --git a/crates/openhuman-core/src/flows/ops/resume.rs b/crates/openhuman-core/src/flows/ops/resume.rs
index e6562887e1..4d5a5cf5df 100644
--- a/crates/openhuman-core/src/flows/ops/resume.rs
+++ b/crates/openhuman-core/src/flows/ops/resume.rs
@@ -18,6 +18,7 @@ use super::*;
/// unknown) is rejected outright — resuming an already-settled thread_id is
/// no longer treated as a harmless no-op, it's a clear error.
pub async fn flows_resume(
+ ctx: &crate::core::runtime::DispatchCtx,
config: &Config,
flow_id: &str,
thread_id: &str,
@@ -209,6 +210,7 @@ pub async fn flows_resume(
let compiled = tinyflows::compiler::compile(&flow.graph).map_err(|e| e.to_string())?;
let config_arc = Arc::new(config.clone());
let caps = crate::flows::tinyflows::build_capabilities(
+ ctx,
config_arc.clone(),
format!("flow:{flow_id}"),
Some(FlowRunContext {
diff --git a/crates/openhuman-core/src/flows/ops/run.rs b/crates/openhuman-core/src/flows/ops/run.rs
index 3c77b47d12..a5bae19b43 100644
--- a/crates/openhuman-core/src/flows/ops/run.rs
+++ b/crates/openhuman-core/src/flows/ops/run.rs
@@ -23,6 +23,7 @@ use super::*;
/// [`tinyflows::engine::RunInput`]. A declared-input problem (missing required
/// value, wrong type, undeclared key) is rejected before any run row exists.
pub async fn flows_run(
+ ctx: &crate::core::runtime::DispatchCtx,
config: &Config,
flow_id: &str,
input: Value,
@@ -46,6 +47,7 @@ pub async fn flows_run(
publish_flow_run_started(flow_id, &thread_id);
run_flow_body(
+ ctx.clone(),
Arc::new(config.clone()),
prepared.flow,
flow_id.to_string(),
@@ -84,6 +86,7 @@ pub async fn flows_run(
/// payload and the flow's declared inputs. Both are validated synchronously, so
/// the agent still gets an immediate, actionable error for a bad call.
pub async fn flows_run_detached(
+ ctx: &crate::core::runtime::DispatchCtx,
config: &Config,
flow_id: &str,
input: Value,
@@ -115,12 +118,14 @@ pub async fn flows_run_detached(
);
let config_arc = Arc::new(config.clone());
+ let body_ctx = ctx.clone();
let flow = prepared.flow;
let flow_id_owned = flow_id.to_string();
let body_thread_id = thread_id.clone();
tokio::spawn(crate::core::runtime::context::CoreContext::propagate(
async move {
if let Err(e) = run_flow_body(
+ body_ctx,
config_arc,
flow,
flow_id_owned,