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
feat(flows): add node contracts for tinyflows capabilities
Steven Enamakel25a98bebf7e0
diff --git a/crates/openhuman-core/src/flows/mod.rs b/crates/openhuman-core/src/flows/mod.rsindex 631f1fac55..e797832013 100644--- a/crates/openhuman-core/src/flows/mod.rs+++ b/crates/openhuman-core/src/flows/mod.rs@@ -59,10 +59,7 @@ pub use schemas::{// lives in the sibling `tinyflows` domain and persists each finished step onto// the `flow_runs` row through this function as the run executes.pub use store::{kv_get, kv_set, upsert_flow_run_step};-pub use {- node_contracts::all_node_kind_contracts, node_contracts::node_kind_contract,- node_contracts::render_node_kinds_line, node_contracts::render_node_kinds_required,-};+pub use {node_contracts::all_node_kind_contracts, node_contracts::node_kind_contract};// Flow memory scoping (`flow:<id>` tags over memory v2) lives in// `memory_tools`, the sibling that owns the agent tools; the digest// subscriber, `flows_delete` and the tinyflows `memory` node adapter reach thediff --git a/crates/openhuman-core/src/flows/node_contracts.rs b/crates/openhuman-core/src/flows/node_contracts.rsindex 997e0eb4e8..653529e0c6 100644--- a/crates/openhuman-core/src/flows/node_contracts.rs+++ b/crates/openhuman-core/src/flows/node_contracts.rs@@ -168,67 +168,6 @@ pub fn node_kind_contract(kind: &str) -> Option<NodeKindContract> {tinyflows::catalog::contract_for(kind).map(apply_host_overlay)}-/// Renders the compact, one-line-per-kind node-kind enumeration used to keep-/// `propose_workflow`'s description honest against the typed contracts (drift-/// test). Format: `kind [required config.a/config.b; optional config.c] —-/// summary`, joined by ` | `.-pub fn render_node_kinds_line() -> String {- all_node_kind_contracts()- .iter()- .map(|c| {- let required: Vec<&str> = c- .config_fields- .iter()- .filter(|f| f.required)- .map(|f| f.name.as_str())- .collect();- let optional: Vec<&str> = c- .config_fields- .iter()- .filter(|f| !f.required)- .map(|f| f.name.as_str())- .collect();- let mut cfg = String::new();- if !required.is_empty() {- cfg.push_str(&format!("required config.{}", required.join("/config.")));- }- if !optional.is_empty() {- if !cfg.is_empty() {- cfg.push_str("; ");- }- cfg.push_str(&format!("optional config.{}", optional.join("/config.")));- }- if cfg.is_empty() {- format!("{} ({})", c.kind, c.summary)- } else {- format!("{} [{}] — {}", c.kind, cfg, c.summary)- }- })- .collect::<Vec<_>>()- .join(" | ")-}--/// Renders the node kinds and only their required configuration fields.-pub fn render_node_kinds_required() -> String {- all_node_kind_contracts()- .iter()- .map(|c| {- let required: Vec<&str> = c- .config_fields- .iter()- .filter(|f| f.required)- .map(|f| f.name.as_str())- .collect();- if required.is_empty() {- c.kind.clone()- } else {- format!("{}(config.{})", c.kind, required.join(", config."))- }- })- .collect::<Vec<_>>()- .join(", ")-}-#[cfg(test)]#[path = "node_contracts_tests.rs"]mod tests;diff --git a/crates/openhuman-core/src/flows/node_contracts_tests.rs b/crates/openhuman-core/src/flows/node_contracts_tests.rsindex 24e4175f1b..349ff38b36 100644--- a/crates/openhuman-core/src/flows/node_contracts_tests.rs+++ b/crates/openhuman-core/src/flows/node_contracts_tests.rs@@ -79,23 +79,3 @@ fn merge_has_no_overlay_and_stays_portable() {tinyflows::catalog::contract_for("merge").unwrap());}--#[test]-fn rendered_line_covers_every_kind_and_required_field() {- let line = render_node_kinds_line();- for c in all_node_kind_contracts() {- assert!(- line.contains(&c.kind),- "rendered line missing kind {}",- c.kind- );- for f in c.config_fields.iter().filter(|f| f.required) {- assert!(- line.contains(&format!("config.{}", f.name)),- "rendered line missing required field config.{} for {}",- f.name,- c.kind- );- }- }-}diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/llm.rs b/crates/openhuman-core/src/flows/tinyflows/caps/llm.rsindex 151c9c6659..04b4a158be 100644--- a/crates/openhuman-core/src/flows/tinyflows/caps/llm.rs+++ b/crates/openhuman-core/src/flows/tinyflows/caps/llm.rs@@ -102,7 +102,7 @@ impl LlmProvider for OpenHumanLlm {.map_err(|e| EngineError::Capability(e.to_string()))?;// `create_chat_provider` handed back the role's default model. If the node// pinned a raw/BYOK id, forward it verbatim instead (issue #4598).- let model = resolve_completion_model(node_model, model);+ let model = agent_prompt::resolve_completion_model(node_model, model, is_raw_passthrough_model);let mut model_request = ModelRequest::new(messagesdiff --git a/crates/openhuman-core/src/flows/tinyflows/caps/prompt.rs b/crates/openhuman-core/src/flows/tinyflows/caps/prompt.rsindex 5cbce31f00..8797ee1242 100644--- a/crates/openhuman-core/src/flows/tinyflows/caps/prompt.rs+++ b/crates/openhuman-core/src/flows/tinyflows/caps/prompt.rs@@ -73,28 +73,6 @@ pub(crate) fn model_response_to_completion_value(})}-/// Select the model an `agent` node completion actually runs on.-///-/// `resolved_model` is what [`create_chat_provider`] returned for the node's-/// mapped workload role. A node may instead pin a **raw/BYOK** model id-/// (e.g. `claude-opus-4`) that [`role_for_model_tier`] collapsed to the `chat`-/// role — in that case the pinned id, not the role default, is the model the-/// user selected, so it is forwarded verbatim (issue #4598). Managed tiers and-/// every `hint:*` alias fall through to `resolved_model` unchanged.-pub(crate) fn resolve_completion_model(node_model: Option<&str>, resolved_model: String) -> String {- match node_model {- Some(pinned) if is_raw_passthrough_model(pinned) => {- tracing::debug!(- target: "flows",- raw_model = pinned,- "[flows] llm.complete: forwarding raw/BYOK node model verbatim (not a managed tier)"- );- pinned.to_string()- }- _ => resolved_model,- }-}-#[cfg(test)]#[path = "prompt_tests.rs"]mod tests;diff --git a/crates/openhuman-core/src/flows/tools.rs b/crates/openhuman-core/src/flows/tools.rsindex 0bb1c057d3..d6e6cdf036 100644--- a/crates/openhuman-core/src/flows/tools.rs+++ b/crates/openhuman-core/src/flows/tools.rs@@ -53,7 +53,7 @@ impl Tool for ProposeWorkflowTool {// `workflow_builder`'s prompt carries an index — and it shipped on// every request of every agent holding this tool.//- // `render_node_kinds_required()` reduces it to the one thing a caller+ // `tinyflows::catalog::render_node_kinds_required` reduces it to the one thing a caller// cannot recover from a failed call: which kinds exist and what config// each cannot be built without (401 bytes). Everything else is one// `get_node_kind_contract { kind }` away.@@ -89,7 +89,9 @@ impl Tool for ProposeWorkflowTool {Call `get_node_kind_contract {{ kind }}` for a kind's optional fields, ports, \a worked example, and its gotchas — it is generated from the catalog the \validator enforces, so it is always current.",- kinds = crate::flows::render_node_kinds_required()+ kinds = tinyflows::catalog::render_node_kinds_required(+ &crate::flows::all_node_kind_contracts()+ ))}).as_str()