Skip to content

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

chore: files changed crates/openhuman-core/src/flows/ops/builder_gates.rs,crates/openhuman-core/src/

Steven Enamakel4a8ef2cc39e2
diff --git a/crates/openhuman-core/src/flows/ops/builder_gates.rs b/crates/openhuman-core/src/flows/ops/builder_gates.rs
index aa080f831e..bbc1869813 100644
--- a/crates/openhuman-core/src/flows/ops/builder_gates.rs
+++ b/crates/openhuman-core/src/flows/ops/builder_gates.rs
@@ -68,7 +68,11 @@ pub(crate) fn validate_upload_paths(graph: &WorkflowGraph) -> Vec<String> {
errors
}
-pub(crate) async fn run_builder_gates(config: &Config, graph: &WorkflowGraph) -> Vec<String> {
+pub(crate) async fn run_builder_gates(
+ ctx: &DispatchCtx,
+ config: &Config,
+ graph: &WorkflowGraph,
+) -> Vec<String> {
// The stack order, short-circuiting and mock-run preflight are
// `tinyflows::gates::builder_failures`'; the host supplies the stages that
// depend on its vocabulary (agent registry, connections, tool catalog).
@@ -76,7 +80,7 @@ pub(crate) async fn run_builder_gates(config: &Config, graph: &WorkflowGraph) ->
// Provider connectivity (B45) is deliberately NOT a stage: it is an advisory
// `inference_status` on the proposal payload and a run-time rejection, so a
// graph that is only "not runnable yet" can still be shown to the user.
- let host = OpenHumanBuilderGateHost { config };
+ let host = OpenHumanBuilderGateHost { ctx, config };
match tinyflows::gates::builder_failures(
graph,
&host,
@@ -99,6 +103,7 @@ pub(crate) async fn run_builder_gates(config: &Config, graph: &WorkflowGraph) ->
/// Host side of the builder gate stack: the four `HostGateStage`s and the
/// saved-workflow lookup the compatibility walk needs.
struct OpenHumanBuilderGateHost<'a> {
+ ctx: &'a DispatchCtx,
config: &'a Config,
}
@@ -130,8 +135,8 @@ impl tinyflows::gates::BuilderGateHost for OpenHumanBuilderGateHost<'_> {
use tinyflows::gates::HostGateStage;
Ok(match stage {
HostGateStage::ToolPolicy => validate_upload_paths(graph),
- HostGateStage::AgentReferences => validate_agent_refs(self.config, graph).await,
- HostGateStage::Connections => validate_connection_refs(self.config, graph).await,
+ HostGateStage::AgentReferences => validate_agent_refs(self.ctx, self.config, graph).await,
+ HostGateStage::Connections => validate_connection_refs(self.ctx, self.config, graph).await,
HostGateStage::ToolContracts => validate_tool_contracts(self.config, graph).await,
})
}
@@ -146,7 +151,11 @@ impl tinyflows::gates::BuilderGateHost for OpenHumanBuilderGateHost<'_> {
/// on the canvas may save a work-in-progress graph); passing `strict: true`
/// opts that call into the *same* gates an agent save must pass, so the two
/// planes converge on one definition instead of diverging.
-pub(crate) async fn strict_gate(config: &Config, graph_json: &Value) -> Result<(), String> {
+pub(crate) async fn strict_gate(
+ ctx: &DispatchCtx,
+ config: &Config,
+ graph_json: &Value,
+) -> Result<(), String> {
let graph = tinyflows::migrate::deserialize_graph(graph_json.clone())?;
let structural = tinyflows::validate::validate_all(&graph);
if !structural.is_empty() {
@@ -156,7 +165,7 @@ pub(crate) async fn strict_gate(config: &Config, graph_json: &Value) -> Result<(
messages.join("\n")
));
}
- let gate_errors = run_builder_gates(config, &graph).await;
+ let gate_errors = run_builder_gates(ctx, config, &graph).await;
if !gate_errors.is_empty() {
return Err(format!(
"strict validation failed:\n{}",
@@ -191,6 +200,7 @@ pub(crate) async fn strict_gate(config: &Config, graph_json: &Value) -> Result<(
/// graph.
#[allow(clippy::too_many_arguments)]
pub(crate) async fn build_builder_proposal(
+ ctx: &DispatchCtx,
config: &Config,
retry_tool: &str,
name: &str,
@@ -203,7 +213,7 @@ pub(crate) async fn build_builder_proposal(
) -> Result<Value, String> {
// The full builder hard-gate stack, run through the single canonical
// runner so every proposal/save/strict-RPC path gates identically (F3).
- let gate_errors = run_builder_gates(config, graph).await;
+ let gate_errors = run_builder_gates(ctx, config, graph).await;
if !gate_errors.is_empty() {
return Err(format!(
"{}\n\nFix these and call {retry_tool} again.",
@@ -218,8 +228,7 @@ pub(crate) async fn build_builder_proposal(
// toolkits this graph needs and whether they're connected, so it can render
// "Connect <toolkit>" CTAs instead of a bare gate error later.
let required_connections =
- compute_required_connections(&crate::core::runtime::DispatchCtx::ambient(), config, graph)
- .await;
+ compute_required_connections(ctx, config, graph).await;
// B45 (design correction): the LLM-provider-connectivity evaluation is
// ADVISORY here, never a rejection — `run_builder_gates` above no longer
// includes it (that used to hard-block `propose_workflow`/`edit_workflow`
@@ -342,7 +351,11 @@ pub(crate) async fn build_builder_proposal(
/// non-harness `agent_ref`s previously triggered one `config_rpc::
/// load_config_with_timeout` per node; an all-`Harness`/no-custom-ref graph
/// still never reads it at all.
-pub(crate) async fn validate_agent_refs(config: &Config, graph: &WorkflowGraph) -> Vec<String> {
+pub(crate) async fn validate_agent_refs(
+ ctx: &DispatchCtx,
+ config: &Config,
+ graph: &WorkflowGraph,
+) -> Vec<String> {
use crate::agent::harness::host_definition::AgentDefinitionRegistry;
use crate::agent::registry::AgentRegistryEntry;
use crate::flows::tinyflows::caps::{route_for_agent_ref, AgentRoute};
@@ -387,11 +400,7 @@ pub(crate) async fn validate_agent_refs(config: &Config, graph: &WorkflowGraph)
AgentRoute::RegistryFallback => {
if custom_registry.is_none() {
custom_registry = Some(
- crate::agent::registry::list_agents(
- &crate::core::runtime::DispatchCtx::ambient(),
- true,
- )
- .await,
+ crate::agent::registry::list_agents(ctx, true).await,
);
}
match custom_registry.as_ref().expect("just populated") {
diff --git a/crates/openhuman-core/src/flows/ops/connection_ref_gate.rs b/crates/openhuman-core/src/flows/ops/connection_ref_gate.rs
index 1e8730ff48..5fe82d5e99 100644
--- a/crates/openhuman-core/src/flows/ops/connection_ref_gate.rs
+++ b/crates/openhuman-core/src/flows/ops/connection_ref_gate.rs
@@ -57,13 +57,12 @@ fn first_connection_ref_for_toolkit(conns: &[FlowConnection], toolkit: &str) ->
/// so a real connection is never false-rejected during an outage — but the
/// toolkit-mismatch check, which needs no I/O, still runs.
pub(crate) async fn validate_connection_refs(
+ ctx: &crate::core::runtime::DispatchCtx,
config: &Config,
graph: &WorkflowGraph,
) -> Vec<String> {
- // Transitional (#7801): the builder gates carry no context yet.
- let ctx = crate::core::runtime::DispatchCtx::ambient();
let connections: Option<Vec<FlowConnection>> =
- match crate::integrations::composio::ops::composio_list_connections(&ctx, config).await {
+ match crate::integrations::composio::ops::composio_list_connections(ctx, config).await {
Ok(outcome) => Some(build_flow_connections(
outcome.value.connections,
Vec::new(),
diff --git a/crates/openhuman-core/src/flows/schemas_handlers.rs b/crates/openhuman-core/src/flows/schemas_handlers.rs
index 378ab2e687..8c238c2fd6 100644
--- a/crates/openhuman-core/src/flows/schemas_handlers.rs
+++ b/crates/openhuman-core/src/flows/schemas_handlers.rs
@@ -16,7 +16,7 @@ fn handle_create(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFutu
.and_then(Value::as_bool)
.unwrap_or(false)
{
- ops::strict_gate(&config, &graph).await?;
+ ops::strict_gate(&ctx, &config, &graph).await?;
}
to_json(ops::flows_create(&config, name, graph, require_approval).await?)
})
diff --git a/crates/openhuman-core/src/flows/tools.rs b/crates/openhuman-core/src/flows/tools.rs
index 97bc27fe1a..287b1a0f3d 100644
--- a/crates/openhuman-core/src/flows/tools.rs
+++ b/crates/openhuman-core/src/flows/tools.rs
@@ -113,6 +113,17 @@ impl Tool for ProposeWorkflowTool {
}
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 name = match args.get("name").and_then(Value::as_str).map(str::trim) {
Some(name) if !name.is_empty() => name.to_string(),
_ => return Ok(ToolResult::error("Missing 'name' parameter".to_string())),
@@ -157,6 +168,7 @@ impl Tool for ProposeWorkflowTool {
// compatibility checks for literal workflow_id children, which cannot
// be detected by graph-only validation because they require the store.
match build_builder_proposal(
+ &ctx,
&self.config,
"propose_workflow",
&name,