Skip to content

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

refactor(flows): improve trigger configuration extraction

Steven Enamakela8d8ad85f42c
diff --git a/crates/openhuman-core/src/flows/README.md b/crates/openhuman-core/src/flows/README.md
index 4cd9ae59aa..c55ef89056 100644
--- a/crates/openhuman-core/src/flows/README.md
+++ b/crates/openhuman-core/src/flows/README.md
@@ -4,9 +4,10 @@ Saved automation workflows: the graphs a user builds on the Workflows canvas,
or that the workflow copilot builds for them in chat. This domain owns the
saved-flow lifecycle (create, edit, enable, run, resume, cancel), the bridge
from trigger events to runs, the agent tools and sub-agents that author and
-suggest flows, and the adapters that let the vendored `tinyflows` engine call
-real OpenHuman services. The engine itself (graph model, validation,
-compilation, execution) lives in [`vendor/tinyflows/`](../../../../vendor/tinyflows/).
+suggest flows, and the host callbacks that TinyFlows invokes for OpenHuman
+services. TinyFlows owns graph validation, compilation, execution, and catalog
+behavior; OpenHuman reaches these through [`tinyflows-bus`](../../../../vendor/tinyflows/)
+and serves the product-specific callbacks.
Callers are the JSON-RPC/CLI surface (`flows.*`, used by the Workflows UI), the
event bus (cron ticks and Composio triggers), and agents that hold the flow
@@ -23,24 +24,23 @@ tools.
v v | Composio trigger
schemas.rs ---------> ops/* <----------------- bus/trigger.rs
| |
- validate, gate, | | compile + run
- persist | |
+ policy, | | trigger dispatch
+ RPC mapping | |
v v
- store.rs / draft_store.rs tinyflows engine (vendor/tinyflows)
- (FlowCatalogDocuments on the |
- storage ports) | capability traits
- v
- tinyflows/caps (agent, llm, tools,
- http, code, memory, state store)
- |
- v
- OpenHuman services: harness, Composio,
- native tools, memory, approval gate
+ TinyFlows TinyBus contracts
+ Authoring / Catalog / Runs / Portability
+ | ^
+ CatalogStorage callback | CapsHost callbacks
+ | |
+ host storage OpenHuman services: harness,
+ Composio, native tools, memory,
+ HTTP and approval policy
```
-`ops/` is the business layer. Everything else either calls into it (RPC
-handlers, agent tools, the trigger subscriber) or is called by it (the store,
-the engine, the capability seam).
+`ops/` is the host business layer. RPC handlers, agent tools, and the trigger
+subscriber call into it. It calls TinyFlows through bus contracts and applies
+OpenHuman policy; TinyFlows calls back through the host's scoped storage and
+capability objects.
### Saving a flow
@@ -102,8 +102,9 @@ automatic dispatch based on its trigger node:
| `webhook` | Not implemented. Enabling logs an actionable warning; incoming webhook requests are observed but never start a run. |
| `manual` and others | No automatic dispatch. |
-`flows_update` rebinds a schedule when an enabled flow's trigger kind or config
-changes, so a new cron expression takes effect. At boot,
+`flows_update` rebinds a schedule when its normalized trigger kind or typed
+schedule changes, so a new cron expression takes effect without rebinding for
+pinned-input or unrelated graph edits. At boot,
`reconcile_schedule_triggers_on_boot` (called from [`core/runtime/services.rs`](../core/runtime/services.rs))
re-arms schedules for every enabled flow.
@@ -246,8 +247,8 @@ Top level:
| `mod.rs` | Module declarations and re-exports: node contracts and flow-memory helpers. |
| [`ops.rs`](./ops.rs), `ops/` | Business operations returning `Outcome<T>`. See the table below. |
| [`schemas.rs`](./schemas.rs), `schemas/`, [`schemas_handlers.rs`](./schemas_handlers.rs) | Controller schemas (split into `builder_schemas.rs`, `definition_schemas.rs`, `draft_schemas.rs`, `run_schemas.rs`) and thin handlers that load config, read params and call `ops::flows_*`. |
-| [`store.rs`](./store.rs) | Binds `FlowCatalogDocuments` to this host's storage (`scoped`, `documents`). Every function only substitutes the catalog; anything else in a body is host policy leaking into persistence. |
-| `draft_store.rs` | Same binding for the catalog's drafts. |
+| [`store.rs`](./store.rs) | Translates host flow operations to TinyFlows Catalog bus requests; the module owns catalog persistence through the scoped `CatalogStorage` callback. |
+| `draft_store.rs` | Compatibility adapter for draft requests over TinyFlows' Catalog contract. |
| [`bus.rs`](./bus.rs), `bus/` | The trigger and run-digest subscribers. |
| [`runs_adapter.rs`](./runs_adapter.rs), `runs_adapter/` | Scope-bound CatalogStorage and CapsHost ownership, Runs Start/Poll/Cancel calls, cursor projection, and legacy RPC result mapping. |
| [`tools.rs`](./tools.rs) | `ProposeWorkflowTool` (`propose_workflow`) and `RunFlowTool` (`run_flow`). |
diff --git a/crates/openhuman-core/src/flows/bus.rs b/crates/openhuman-core/src/flows/bus.rs
index 1350be39fd..b46a340612 100644
--- a/crates/openhuman-core/src/flows/bus.rs
+++ b/crates/openhuman-core/src/flows/bus.rs
@@ -17,7 +17,7 @@ mod trigger;
pub use run_digest::FlowRunDigestSubscriber;
pub use trigger::FlowTriggerSubscriber;
-pub(crate) use trigger::describe_trigger;
+pub(crate) use trigger::{describe_trigger, extract_trigger_config, extract_trigger_kind};
// Private helpers and shared imports the colocated tests reach through
// `use super::*`.
diff --git a/crates/openhuman-core/src/flows/bus/trigger.rs b/crates/openhuman-core/src/flows/bus/trigger.rs
index 1831288768..cd1f6273ec 100644
--- a/crates/openhuman-core/src/flows/bus/trigger.rs
+++ b/crates/openhuman-core/src/flows/bus/trigger.rs
@@ -16,6 +16,7 @@ use std::pin::Pin;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex, RwLock};
use tinybus::EventHandler;
+use tinyflows::model::TriggerKind;
use tinyflows_catalog::Flow;
use tokio::sync::{mpsc, Mutex as AsyncMutex};
@@ -37,6 +38,17 @@ where
.map_err(|error| error.to_string())
}
+// Temporary reproduction of the pre-cleanup helper for the red regression
+// run: it compares the full trigger config, including pinned inputs.
+pub(crate) fn extract_trigger_kind(flow: &Flow) -> Option<TriggerKind> {
+ let trigger = flow.graph.trigger()?;
+ serde_json::from_value(trigger.config.get("trigger_kind")?.clone()).ok()
+}
+
+pub(crate) fn extract_trigger_config(flow: &Flow) -> Option<&Value> {
+ Some(&flow.graph.trigger()?.config)
+}
+
/// Ask TinyFlows for normalized trigger metadata used by host bindings.
pub(crate) fn describe_trigger(
config: &Config,
diff --git a/crates/openhuman-core/src/flows/ops/updates.rs b/crates/openhuman-core/src/flows/ops/updates.rs
index 1be6107c29..c628b13d77 100644
--- a/crates/openhuman-core/src/flows/ops/updates.rs
+++ b/crates/openhuman-core/src/flows/ops/updates.rs
@@ -228,8 +228,9 @@ async fn flows_update_inner(
}
if graph_changed && updated.enabled {
- let trigger_unchanged = existing.graph.trigger().map(|trigger| &trigger.config)
- == updated.graph.trigger().map(|trigger| &trigger.config);
+ let trigger_unchanged = bus::extract_trigger_kind(&existing)
+ == bus::extract_trigger_kind(&updated)
+ && bus::extract_trigger_config(&existing) == bus::extract_trigger_config(&updated);
if !trigger_unchanged {
tracing::debug!(target: "flows", flow_id = %id, "[flows] flows_update: trigger changed on an enabled flow — rebinding automatic-dispatch trigger");
unbind_trigger(config, &existing);
diff --git a/crates/openhuman-core/src/flows/ops_triggers_and_resume_tests.rs b/crates/openhuman-core/src/flows/ops_triggers_and_resume_tests.rs
index 56e91a1112..4ff435ede8 100644
--- a/crates/openhuman-core/src/flows/ops_triggers_and_resume_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_triggers_and_resume_tests.rs
@@ -238,9 +238,25 @@ async fn flows_update_does_not_rebind_schedule_for_pinned_input_changes() {
flows_set_enabled(&config, &created.value.id, true)
.await
.unwrap();
- let original_job = crate::cron::find_flow_schedule_job(&config, &created.value.id)
+ let job = crate::cron::find_flow_schedule_job(&config, &created.value.id)
.unwrap()
.expect("cron job bound on enable");
+ let run_at = chrono::DateTime::parse_from_rfc3339("2026-10-20T09:00:00Z")
+ .unwrap()
+ .with_timezone(&chrono::Utc);
+ crate::cron::record_run(
+ &config,
+ &job.id,
+ run_at,
+ run_at,
+ "ok",
+ Some("prior schedule result"),
+ 17,
+ )
+ .unwrap();
+ let original_job = crate::cron::find_flow_schedule_job(&config, &created.value.id)
+ .unwrap()
+ .expect("seeded schedule job remains registered");
let mut graph = schedule_trigger_graph("0 9 * * *");
graph["nodes"][0]["config"]["inputs"] = json!({"team": "platform"});
@@ -252,6 +268,9 @@ async fn flows_update_does_not_rebind_schedule_for_pinned_input_changes() {
.unwrap()
.expect("schedule job remains bound after input-only edit");
assert_eq!(job.id, original_job.id, "input edits must preserve the binding");
+ assert_eq!(job.last_run, original_job.last_run);
+ assert_eq!(job.last_status, original_job.last_status);
+ assert_eq!(job.last_output, original_job.last_output);
assert_eq!(job.expression, original_job.expression);
}