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(tools): add schema cache for tool parameter validation
Steven Enamakel9f251042253e
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/parameters/steer_subagent.json b/crates/openhuman-core/src/agent/orchestration/tools/parameters/steer_subagent.jsonnew file mode 100644index 0000000000..29491fb99d--- /dev/null+++ b/crates/openhuman-core/src/agent/orchestration/tools/parameters/steer_subagent.json@@ -0,0 +1,29 @@+{+ "type": "object",+ "required": [+ "message"+ ],+ "properties": {+ "task_id": {+ "type": "string",+ "description": "Transient task_id returned by reusable async delegation."+ },+ "subagent_session_id": {+ "type": "string",+ "description": "Durable subagent_session_id returned by reusable async delegation. Preferred over task_id for cross-turn messaging."+ },+ "message": {+ "type": "string",+ "description": "Instruction or data to inject into the running sub-agent."+ },+ "mode": {+ "type": "string",+ "enum": [+ "steer",+ "collect"+ ],+ "default": "steer",+ "description": "steer = a new instruction the sub-agent must address; collect = silent additional context."+ }+ }+}diff --git a/crates/openhuman-core/src/agent/orchestration/tools/steer_subagent.rs b/crates/openhuman-core/src/agent/orchestration/tools/steer_subagent.rsindex 86356179ed..a4e53db3f1 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/steer_subagent.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/steer_subagent.rs@@ -7,6 +7,7 @@//! redirect or feed data to a running sub-agent//! without waiting for it to finish or restarting it. Mirrors Codex `send_input`.+use crate::tools::schema_cache::static_schema;use crate::agent::harness::fork_context::ParentExecutionContext;use crate::agent::orchestration::running_subagents::{self, SteerError};use async_trait::async_trait;@@ -72,30 +73,7 @@ impl Tool for SteerSubagentTool {}fn parameters_schema(&self) -> serde_json::Value {- json!({- "type": "object",- "required": ["message"],- "properties": {- "task_id": {- "type": "string",- "description": "Transient task_id returned by reusable async delegation."- },- "subagent_session_id": {- "type": "string",- "description": "Durable subagent_session_id returned by reusable async delegation. Preferred over task_id for cross-turn messaging."- },- "message": {- "type": "string",- "description": "Instruction or data to inject into the running sub-agent."- },- "mode": {- "type": "string",- "enum": ["steer", "collect"],- "default": "steer",- "description": "steer = a new instruction the sub-agent must address; collect = silent additional context."- }- }- })+ static_schema!(include_str!("parameters/steer_subagent.json"))}fn permission_level(&self) -> PermissionLevel {@@ -221,3 +199,7 @@ impl SteerSubagentTool {#[cfg(test)]#[path = "steer_subagent_tests.rs"]mod tests;++#[cfg(test)]+#[path = "steer_subagent_schema_tests.rs"]+mod schema_tests;diff --git a/crates/openhuman-core/src/agent/orchestration/tools/steer_subagent_schema_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/steer_subagent_schema_tests.rsnew file mode 100644index 0000000000..c884645544--- /dev/null+++ b/crates/openhuman-core/src/agent/orchestration/tools/steer_subagent_schema_tests.rs@@ -0,0 +1,35 @@+use super::*;+use serde_json::json;++fn expected_steer_subagent() -> serde_json::Value {+ json!({+ "type": "object",+ "required": ["message"],+ "properties": {+ "task_id": {+ "type": "string",+ "description": "Transient task_id returned by reusable async delegation."+ },+ "subagent_session_id": {+ "type": "string",+ "description": "Durable subagent_session_id returned by reusable async delegation. Preferred over task_id for cross-turn messaging."+ },+ "message": {+ "type": "string",+ "description": "Instruction or data to inject into the running sub-agent."+ },+ "mode": {+ "type": "string",+ "enum": ["steer", "collect"],+ "default": "steer",+ "description": "steer = a new instruction the sub-agent must address; collect = silent additional context."+ }+ }+ })+}++#[test]+fn steer_subagent_static_schema_matches_json_literal() {+ let tool = todo!("construct tool");+ assert_eq!(Tool::parameters_schema(&tool), expected_steer_subagent());+}diff --git a/crates/openhuman-core/src/cron/tools/add.rs b/crates/openhuman-core/src/cron/tools/add.rsindex e9735a4208..28a9d9d7f2 100644--- a/crates/openhuman-core/src/cron/tools/add.rs+++ b/crates/openhuman-core/src/cron/tools/add.rs@@ -1,3 +1,4 @@+use crate::tools::schema_cache::static_schema;use crate::config::Config;use crate::cron::job_builder::{create_agent_job, AgentJobInput};use crate::cron::origin::{current_job_origin, current_turn_may_skip_approval};@@ -48,75 +49,7 @@ impl Tool for CronAddTool {}fn parameters_schema(&self) -> serde_json::Value {- json!({- "type": "object",- "properties": {- "name": { "type": "string", "description": "Short human-readable name for the job (e.g. 'drink_water_reminder'). Always provide a name." },- "schedule": {- "description": "Schedule: cron expression, one-shot at time, or fixed interval.",- "oneOf": [- {- "type": "object",- "description": "Repeating cron schedule. 'tz' is an IANA timezone (e.g. 'America/Los_Angeles'); defaults to device-local timezone.",- "properties": {- "kind": { "type": "string", "const": "cron" },- "expr": { "type": "string", "description": "Cron expression (5, 6, or 7 fields). For agent jobs, consecutive runs must be at least 5 minutes apart." },- "tz": { "type": "string", "description": "Optional IANA timezone name" },- "active_hours": {- "type": "object",- "description": "Optional: only run during these local hours",- "properties": {- "start": { "type": "string", "description": "Start time HH:MM (e.g. '09:00')" },- "end": { "type": "string", "description": "End time HH:MM (e.g. '17:00')" }- },- "required": ["start", "end"],- "additionalProperties": false- }- },- "required": ["kind", "expr"],- "additionalProperties": false- },- {- "type": "object",- "description": "One-shot job that runs once at a specific UTC instant.",- "properties": {- "kind": { "type": "string", "const": "at" },- "at": { "type": "string", "description": "ISO-8601 UTC timestamp" }- },- "required": ["kind", "at"],- "additionalProperties": false- },- {- "type": "object",- "description": "Repeating job that fires every N milliseconds.",- "properties": {- "kind": { "type": "string", "const": "every" },- "every_ms": { "type": "integer", "description": "Interval in milliseconds (must be > 0; at least 300000 = 5 minutes for agent jobs)" }- },- "required": ["kind", "every_ms"],- "additionalProperties": false- }- ]- },- "job_type": { "type": "string", "enum": ["shell", "agent"] },- "command": { "type": "string" },- "prompt": { "type": "string" },- "session_target": { "type": "string", "enum": ["isolated", "current", "main"], "description": "Defaults to 'current' (a fresh run that sees the recent conversation it was created in and replies there) when created inside a conversation, otherwise 'isolated'." },- "model": { "type": "string" },- "delivery": {- "type": "object",- "description": "Delivery config. Defaults to 'origin' (reply into the conversation this job was created in) when created inside a conversation, otherwise 'proactive'. Modes: origin, proactive, announce (needs channel+to), none (silent).",- "properties": {- "mode": { "type": "string", "enum": ["origin", "proactive", "announce", "none"] },- "channel": { "type": "string", "description": "Required for announce mode" },- "to": { "type": "string", "description": "Required for announce mode" },- "best_effort": { "type": "boolean", "default": true }- }- },- "delete_after_run": { "type": "boolean" }- },- "required": ["name", "schedule"]- })+ static_schema!(include_str!("parameters/cron_add.json"))}fn supports_markdown(&self) -> bool {@@ -338,3 +271,7 @@ impl Tool for CronAddTool {#[cfg(test)]#[path = "add_tests.rs"]mod tests;++#[cfg(test)]+#[path = "add_schema_tests.rs"]+mod schema_tests;diff --git a/crates/openhuman-core/src/cron/tools/add_schema_tests.rs b/crates/openhuman-core/src/cron/tools/add_schema_tests.rsnew file mode 100644index 0000000000..b68e873996--- /dev/null+++ b/crates/openhuman-core/src/cron/tools/add_schema_tests.rs@@ -0,0 +1,80 @@+use super::*;+use serde_json::json;++fn expected_cron_add() -> serde_json::Value {+ json!({+ "type": "object",+ "properties": {+ "name": { "type": "string", "description": "Short human-readable name for the job (e.g. 'drink_water_reminder'). Always provide a name." },+ "schedule": {+ "description": "Schedule: cron expression, one-shot at time, or fixed interval.",+ "oneOf": [+ {+ "type": "object",+ "description": "Repeating cron schedule. 'tz' is an IANA timezone (e.g. 'America/Los_Angeles'); defaults to device-local timezone.",+ "properties": {+ "kind": { "type": "string", "const": "cron" },+ "expr": { "type": "string", "description": "Cron expression (5, 6, or 7 fields). For agent jobs, consecutive runs must be at least 5 minutes apart." },+ "tz": { "type": "string", "description": "Optional IANA timezone name" },+ "active_hours": {+ "type": "object",+ "description": "Optional: only run during these local hours",+ "properties": {+ "start": { "type": "string", "description": "Start time HH:MM (e.g. '09:00')" },+ "end": { "type": "string", "description": "End time HH:MM (e.g. '17:00')" }+ },+ "required": ["start", "end"],+ "additionalProperties": false+ }+ },+ "required": ["kind", "expr"],+ "additionalProperties": false+ },+ {+ "type": "object",+ "description": "One-shot job that runs once at a specific UTC instant.",+ "properties": {+ "kind": { "type": "string", "const": "at" },+ "at": { "type": "string", "description": "ISO-8601 UTC timestamp" }+ },+ "required": ["kind", "at"],+ "additionalProperties": false+ },+ {+ "type": "object",+ "description": "Repeating job that fires every N milliseconds.",+ "properties": {+ "kind": { "type": "string", "const": "every" },+ "every_ms": { "type": "integer", "description": "Interval in milliseconds (must be > 0; at least 300000 = 5 minutes for agent jobs)" }+ },+ "required": ["kind", "every_ms"],+ "additionalProperties": false+ }+ ]+ },+ "job_type": { "type": "string", "enum": ["shell", "agent"] },+ "command": { "type": "string" },+ "prompt": { "type": "string" },+ "session_target": { "type": "string", "enum": ["isolated", "current", "main"], "description": "Defaults to 'current' (a fresh run that sees the recent conversation it was created in and replies there) when created inside a conversation, otherwise 'isolated'." },+ "model": { "type": "string" },+ "delivery": {+ "type": "object",+ "description": "Delivery config. Defaults to 'origin' (reply into the conversation this job was created in) when created inside a conversation, otherwise 'proactive'. Modes: origin, proactive, announce (needs channel+to), none (silent).",+ "properties": {+ "mode": { "type": "string", "enum": ["origin", "proactive", "announce", "none"] },+ "channel": { "type": "string", "description": "Required for announce mode" },+ "to": { "type": "string", "description": "Required for announce mode" },+ "best_effort": { "type": "boolean", "default": true }+ }+ },+ "delete_after_run": { "type": "boolean" }+ },+ "required": ["name", "schedule"]+ })+}++#[test]+fn cron_add_static_schema_matches_json_literal() {+ let tool = todo!("construct tool");+ assert_eq!(Tool::parameters_schema(&tool), expected_cron_add());+}diff --git a/crates/openhuman-core/src/cron/tools/parameters/cron_add.json b/crates/openhuman-core/src/cron/tools/parameters/cron_add.jsonnew file mode 100644index 0000000000..ba856da460--- /dev/null+++ b/crates/openhuman-core/src/cron/tools/parameters/cron_add.json@@ -0,0 +1,153 @@+{+ "type": "object",+ "properties": {+ "name": {+ "type": "string",+ "description": "Short human-readable name for the job (e.g. 'drink_water_reminder'). Always provide a name."+ },+ "schedule": {+ "description": "Schedule: cron expression, one-shot at time, or fixed interval.",+ "oneOf": [+ {+ "type": "object",+ "description": "Repeating cron schedule. 'tz' is an IANA timezone (e.g. 'America/Los_Angeles'); defaults to device-local timezone.",+ "properties": {+ "kind": {+ "type": "string",+ "const": "cron"+ },+ "expr": {+ "type": "string",+ "description": "Cron expression (5, 6, or 7 fields). For agent jobs, consecutive runs must be at least 5 minutes apart."+ },+ "tz": {+ "type": "string",+ "description": "Optional IANA timezone name"+ },+ "active_hours": {+ "type": "object",+ "description": "Optional: only run during these local hours",+ "properties": {+ "start": {+ "type": "string",+ "description": "Start time HH:MM (e.g. '09:00')"+ },+ "end": {+ "type": "string",+ "description": "End time HH:MM (e.g. '17:00')"+ }+ },+ "required": [+ "start",+ "end"+ ],+ "additionalProperties": false+ }+ },+ "required": [+ "kind",+ "expr"+ ],+ "additionalProperties": false+ },+ {+ "type": "object",+ "description": "One-shot job that runs once at a specific UTC instant.",+ "properties": {+ "kind": {+ "type": "string",+ "const": "at"+ },+ "at": {+ "type": "string",+ "description": "ISO-8601 UTC timestamp"+ }+ },+ "required": [+ "kind",+ "at"+ ],+ "additionalProperties": false+ },+ {+ "type": "object",+ "description": "Repeating job that fires every N milliseconds.",+ "properties": {+ "kind": {+ "type": "string",+ "const": "every"+ },+ "every_ms": {+ "type": "integer",+ "description": "Interval in milliseconds (must be > 0; at least 300000 = 5 minutes for agent jobs)"+ }+ },+ "required": [+ "kind",+ "every_ms"+ ],+ "additionalProperties": false+ }+ ]+ },+ "job_type": {+ "type": "string",+ "enum": [+ "shell",+ "agent"+ ]+ },+ "command": {+ "type": "string"+ },+ "prompt": {+ "type": "string"+ },+ "session_target": {+ "type": "string",+ "enum": [+ "isolated",+ "current",+ "main"+ ],+ "description": "Defaults to 'current' (a fresh run that sees the recent conversation it was created in and replies there) when created inside a conversation, otherwise 'isolated'."+ },+ "model": {+ "type": "string"+ },+ "delivery": {+ "type": "object",+ "description": "Delivery config. Defaults to 'origin' (reply into the conversation this job was created in) when created inside a conversation, otherwise 'proactive'. Modes: origin, proactive, announce (needs channel+to), none (silent).",+ "properties": {+ "mode": {+ "type": "string",+ "enum": [+ "origin",+ "proactive",+ "announce",+ "none"+ ]+ },+ "channel": {+ "type": "string",+ "description": "Required for announce mode"+ },+ "to": {+ "type": "string",+ "description": "Required for announce mode"+ },+ "best_effort": {+ "type": "boolean",+ "default": true+ }+ }+ },+ "delete_after_run": {+ "type": "boolean"+ }+ },+ "required": [+ "name",+ "schedule"+ ]+}diff --git a/crates/openhuman-core/src/flows/builder_tools/draft_edit.rs b/crates/openhuman-core/src/flows/builder_tools/draft_edit.rsindex 3cfdd64f3f..f8a584e5d0 100644--- a/crates/openhuman-core/src/flows/builder_tools/draft_edit.rs+++ b/crates/openhuman-core/src/flows/builder_tools/draft_edit.rs@@ -1,5 +1,6 @@//! `edit_workflow`: structured incremental edits on a draft (proposal only, F1).+use crate::tools::schema_cache::static_schema;use std::sync::Arc;use async_trait::async_trait;@@ -84,46 +85,7 @@ impl Tool for EditWorkflowTool {}fn parameters_schema(&self) -> Value {- json!({- "type": "object",- "properties": {- "draft_id": {- "type": "string",- "description": "A working draft to edit as the base; the applied edit is written back to it. Provide one of draft_id / flow_id / graph."- },- "flow_id": {- "type": "string",- "description": "The saved flow to edit as the base graph. Provide one of draft_id / flow_id / graph."- },- "graph": {- "type": "object",- "description": "An inline base tinyflows WorkflowGraph to edit. Provide one of draft_id / flow_id / graph.",- "properties": {- "nodes": { "type": "array" },- "edges": { "type": "array" }- }- },- "ops": {- "type": "array",- "description": "The structured edits, applied in order. Each item is { op, ... } — see the tool description for op shapes.",- "items": { "type": "object", "properties": { "op": { "type": "string" } }, "required": ["op"] },- "minItems": 1- },- "name": {- "type": "string",- "description": "Name for the resulting proposed flow. Defaults to the base flow's name."- },- "instruction": {- "type": "string",- "description": "The change that motivated these ops (echoed back on the review card)."- },- "require_approval": {- "type": "boolean",- "description": "Force a human-approval gate on every outbound action once saved. Defaults to true."- }- },- "required": ["ops"]- })+ static_schema!(include_str!("parameters/edit_workflow.json"))}fn permission_level(&self) -> PermissionLevel {@@ -493,3 +455,7 @@ impl Tool for EditWorkflowTool {}}}++#[cfg(test)]+#[path = "draft_edit_schema_tests.rs"]+mod schema_tests;diff --git a/crates/openhuman-core/src/flows/builder_tools/draft_edit_schema_tests.rs b/crates/openhuman-core/src/flows/builder_tools/draft_edit_schema_tests.rsnew file mode 100644index 0000000000..e1d56fed70--- /dev/null+++ b/crates/openhuman-core/src/flows/builder_tools/draft_edit_schema_tests.rs@@ -0,0 +1,51 @@+use super::*;+use serde_json::json;++fn expected_edit_workflow() -> serde_json::Value {+ json!({+ "type": "object",+ "properties": {+ "draft_id": {+ "type": "string",+ "description": "A working draft to edit as the base; the applied edit is written back to it. Provide one of draft_id / flow_id / graph."+ },+ "flow_id": {+ "type": "string",+ "description": "The saved flow to edit as the base graph. Provide one of draft_id / flow_id / graph."+ },+ "graph": {+ "type": "object",+ "description": "An inline base tinyflows WorkflowGraph to edit. Provide one of draft_id / flow_id / graph.",+ "properties": {+ "nodes": { "type": "array" },+ "edges": { "type": "array" }+ }+ },+ "ops": {+ "type": "array",+ "description": "The structured edits, applied in order. Each item is { op, ... } — see the tool description for op shapes.",+ "items": { "type": "object", "properties": { "op": { "type": "string" } }, "required": ["op"] },+ "minItems": 1+ },+ "name": {+ "type": "string",+ "description": "Name for the resulting proposed flow. Defaults to the base flow's name."+ },+ "instruction": {+ "type": "string",+ "description": "The change that motivated these ops (echoed back on the review card)."+ },+ "require_approval": {+ "type": "boolean",+ "description": "Force a human-approval gate on every outbound action once saved. Defaults to true."+ }+ },+ "required": ["ops"]+ })+}++#[test]+fn edit_workflow_static_schema_matches_json_literal() {+ let tool = todo!("construct tool");+ assert_eq!(Tool::parameters_schema(&tool), expected_edit_workflow());+}diff --git a/crates/openhuman-core/src/flows/builder_tools/draft_revise.rs b/crates/openhuman-core/src/flows/builder_tools/draft_revise.rsindex db66595d4d..b7f35e82a2 100644--- a/crates/openhuman-core/src/flows/builder_tools/draft_revise.rs+++ b/crates/openhuman-core/src/flows/builder_tools/draft_revise.rs@@ -1,5 +1,6 @@//! `revise_workflow`: validate a revised draft and emit a proposal (never persists).+use crate::tools::schema_cache::static_schema;use std::sync::Arc;use async_trait::async_trait;@@ -50,33 +51,7 @@ impl Tool for ReviseWorkflowTool {}fn parameters_schema(&self) -> Value {- json!({- "type": "object",- "properties": {- "name": {- "type": "string",- "description": "Human-readable name for the (revised) proposed flow."- },- "graph": {- "type": "object",- "description": "The full REVISED tinyflows WorkflowGraph: { name?, nodes: [...], edges: [...] }. Apply your changes to the prior draft and pass the whole graph — see propose_workflow for node kinds and config shapes.",- "properties": {- "nodes": { "type": "array" },- "edges": { "type": "array" }- },- "required": ["nodes", "edges"]- },- "instruction": {- "type": "string",- "description": "The revision instruction that motivated this change (e.g. 'add a Slack step after the summary'). Echoed back for the review card; does not affect validation."- },- "require_approval": {- "type": "boolean",- "description": "Force a human-approval gate on every outbound action once saved. Defaults to true for agent-proposed flows."- }- },- "required": ["name", "graph"]- })+ static_schema!(include_str!("parameters/revise_workflow.json"))}fn permission_level(&self) -> PermissionLevel {@@ -152,3 +127,7 @@ impl Tool for ReviseWorkflowTool {}}}++#[cfg(test)]+#[path = "draft_revise_schema_tests.rs"]+mod schema_tests;diff --git a/crates/openhuman-core/src/flows/builder_tools/draft_revise_schema_tests.rs b/crates/openhuman-core/src/flows/builder_tools/draft_revise_schema_tests.rsnew file mode 100644index 0000000000..8ea76b2b04--- /dev/null+++ b/crates/openhuman-core/src/flows/builder_tools/draft_revise_schema_tests.rs@@ -0,0 +1,38 @@+use super::*;+use serde_json::json;++fn expected_revise_workflow() -> serde_json::Value {+ json!({+ "type": "object",+ "properties": {+ "name": {+ "type": "string",+ "description": "Human-readable name for the (revised) proposed flow."+ },+ "graph": {+ "type": "object",+ "description": "The full REVISED tinyflows WorkflowGraph: { name?, nodes: [...], edges: [...] }. Apply your changes to the prior draft and pass the whole graph — see propose_workflow for node kinds and config shapes.",+ "properties": {+ "nodes": { "type": "array" },+ "edges": { "type": "array" }+ },+ "required": ["nodes", "edges"]+ },+ "instruction": {+ "type": "string",+ "description": "The revision instruction that motivated this change (e.g. 'add a Slack step after the summary'). Echoed back for the review card; does not affect validation."+ },+ "require_approval": {+ "type": "boolean",+ "description": "Force a human-approval gate on every outbound action once saved. Defaults to true for agent-proposed flows."+ }+ },+ "required": ["name", "graph"]+ })+}++#[test]+fn revise_workflow_static_schema_matches_json_literal() {+ let tool = todo!("construct tool");+ assert_eq!(Tool::parameters_schema(&tool), expected_revise_workflow());+}diff --git a/crates/openhuman-core/src/flows/builder_tools/dry_run.rs b/crates/openhuman-core/src/flows/builder_tools/dry_run.rsindex 759bcf0ea3..3038a5ea35 100644--- a/crates/openhuman-core/src/flows/builder_tools/dry_run.rs+++ b/crates/openhuman-core/src/flows/builder_tools/dry_run.rs@@ -1,5 +1,6 @@//! `dry_run_workflow`: execute a DRAFT against tinyflows MOCK capabilities (ungated, F7).+use crate::tools::schema_cache::static_schema;use std::sync::Arc;use async_trait::async_trait;@@ -142,31 +143,7 @@ impl Tool for DryRunWorkflowTool {}fn parameters_schema(&self) -> Value {- json!({- "type": "object",- "properties": {- "draft_id": {- "type": "string",- "description": "A working draft to simulate. Provide one of draft_id / flow_id / graph (draft_id wins)."- },- "flow_id": {- "type": "string",- "description": "A saved flow to simulate. Provide one of draft_id / flow_id / graph."- },- "graph": {- "type": "object",- "description": "An inline tinyflows WorkflowGraph to simulate: { nodes: [...], edges: [...] }. Provide one of draft_id / flow_id / graph.",- "properties": {- "nodes": { "type": "array" },- "edges": { "type": "array" }- },- "required": ["nodes", "edges"]- },- "input": {- "description": "Optional trigger input passed to the run (defaults to {})."- }- }- })+ static_schema!(include_str!("parameters/dry_run_workflow.json"))}fn permission_level(&self) -> PermissionLevel {@@ -420,3 +397,7 @@ impl Tool for DryRunWorkflowTool {}))?))}}++#[cfg(test)]+#[path = "dry_run_schema_tests.rs"]+mod schema_tests;diff --git a/crates/openhuman-core/src/flows/builder_tools/dry_run_schema_tests.rs b/crates/openhuman-core/src/flows/builder_tools/dry_run_schema_tests.rsnew file mode 100644index 0000000000..83490fcacf--- /dev/null+++ b/crates/openhuman-core/src/flows/builder_tools/dry_run_schema_tests.rs@@ -0,0 +1,36 @@+use super::*;+use serde_json::json;++fn expected_dry_run_workflow() -> serde_json::Value {+ json!({+ "type": "object",+ "properties": {+ "draft_id": {+ "type": "string",+ "description": "A working draft to simulate. Provide one of draft_id / flow_id / graph (draft_id wins)."+ },+ "flow_id": {+ "type": "string",+ "description": "A saved flow to simulate. Provide one of draft_id / flow_id / graph."+ },+ "graph": {+ "type": "object",+ "description": "An inline tinyflows WorkflowGraph to simulate: { nodes: [...], edges: [...] }. Provide one of draft_id / flow_id / graph.",+ "properties": {+ "nodes": { "type": "array" },+ "edges": { "type": "array" }+ },+ "required": ["nodes", "edges"]+ },+ "input": {+ "description": "Optional trigger input passed to the run (defaults to {})."+ }+ }+ })+}++#[test]+fn dry_run_workflow_static_schema_matches_json_literal() {+ let tool = todo!("construct tool");+ assert_eq!(Tool::parameters_schema(&tool), expected_dry_run_workflow());+}diff --git a/crates/openhuman-core/src/flows/builder_tools/parameters/dry_run_workflow.json b/crates/openhuman-core/src/flows/builder_tools/parameters/dry_run_workflow.jsonnew file mode 100644index 0000000000..d38de1736c--- /dev/null+++ b/crates/openhuman-core/src/flows/builder_tools/parameters/dry_run_workflow.json@@ -0,0 +1,32 @@+{+ "type": "object",+ "properties": {+ "draft_id": {+ "type": "string",+ "description": "A working draft to simulate. Provide one of draft_id / flow_id / graph (draft_id wins)."+ },+ "flow_id": {+ "type": "string",+ "description": "A saved flow to simulate. Provide one of draft_id / flow_id / graph."+ },+ "graph": {+ "type": "object",+ "description": "An inline tinyflows WorkflowGraph to simulate: { nodes: [...], edges: [...] }. Provide one of draft_id / flow_id / graph.",+ "properties": {+ "nodes": {+ "type": "array"+ },+ "edges": {+ "type": "array"+ }+ },+ "required": [+ "nodes",+ "edges"+ ]+ },+ "input": {+ "description": "Optional trigger input passed to the run (defaults to {})."+ }+ }+}diff --git a/crates/openhuman-core/src/flows/builder_tools/parameters/edit_workflow.json b/crates/openhuman-core/src/flows/builder_tools/parameters/edit_workflow.jsonnew file mode 100644index 0000000000..c4dea706c5--- /dev/null+++ b/crates/openhuman-core/src/flows/builder_tools/parameters/edit_workflow.json@@ -0,0 +1,56 @@+{+ "type": "object",+ "properties": {+ "draft_id": {+ "type": "string",+ "description": "A working draft to edit as the base; the applied edit is written back to it. Provide one of draft_id / flow_id / graph."+ },+ "flow_id": {+ "type": "string",+ "description": "The saved flow to edit as the base graph. Provide one of draft_id / flow_id / graph."+ },+ "graph": {+ "type": "object",+ "description": "An inline base tinyflows WorkflowGraph to edit. Provide one of draft_id / flow_id / graph.",+ "properties": {+ "nodes": {+ "type": "array"+ },+ "edges": {+ "type": "array"+ }+ }+ },+ "ops": {+ "type": "array",+ "description": "The structured edits, applied in order. Each item is { op, ... } — see the tool description for op shapes.",+ "items": {+ "type": "object",+ "properties": {+ "op": {+ "type": "string"+ }+ },+ "required": [+ "op"+ ]+ },+ "minItems": 1+ },+ "name": {+ "type": "string",+ "description": "Name for the resulting proposed flow. Defaults to the base flow's name."+ },+ "instruction": {+ "type": "string",+ "description": "The change that motivated these ops (echoed back on the review card)."+ },+ "require_approval": {+ "type": "boolean",+ "description": "Force a human-approval gate on every outbound action once saved. Defaults to true."+ }+ },+ "required": [+ "ops"+ ]+}diff --git a/crates/openhuman-core/src/flows/builder_tools/parameters/revise_workflow.json b/crates/openhuman-core/src/flows/builder_tools/parameters/revise_workflow.jsonnew file mode 100644index 0000000000..90ab0584cf--- /dev/null+++ b/crates/openhuman-core/src/flows/builder_tools/parameters/revise_workflow.json@@ -0,0 +1,37 @@+{+ "type": "object",+ "properties": {+ "name": {+ "type": "string",+ "description": "Human-readable name for the (revised) proposed flow."+ },+ "graph": {+ "type": "object",+ "description": "The full REVISED tinyflows WorkflowGraph: { name?, nodes: [...], edges: [...] }. Apply your changes to the prior draft and pass the whole graph — see propose_workflow for node kinds and config shapes.",+ "properties": {+ "nodes": {+ "type": "array"+ },+ "edges": {+ "type": "array"+ }+ },+ "required": [+ "nodes",+ "edges"+ ]+ },+ "instruction": {+ "type": "string",+ "description": "The revision instruction that motivated this change (e.g. 'add a Slack step after the summary'). Echoed back for the review card; does not affect validation."+ },+ "require_approval": {+ "type": "boolean",+ "description": "Force a human-approval gate on every outbound action once saved. Defaults to true for agent-proposed flows."+ }+ },+ "required": [+ "name",+ "graph"+ ]+}diff --git a/crates/openhuman-core/src/flows/builder_tools/parameters/save_workflow.json b/crates/openhuman-core/src/flows/builder_tools/parameters/save_workflow.jsonnew file mode 100644index 0000000000..33277187aa--- /dev/null+++ b/crates/openhuman-core/src/flows/builder_tools/parameters/save_workflow.json@@ -0,0 +1,37 @@+{+ "type": "object",+ "properties": {+ "flow_id": {+ "type": "string",+ "description": "Id of the EXISTING saved flow to write the graph to (the persistence target — always required)."+ },+ "draft_id": {+ "type": "string",+ "description": "A working draft whose graph to persist onto the flow. Provide this OR inline `graph`; if both are given, draft_id wins."+ },+ "graph": {+ "type": "object",+ "description": "The full tinyflows WorkflowGraph to persist: { name?, nodes: [...], edges: [...] }. Provide this OR `draft_id`. Same shape as propose_workflow.",+ "properties": {+ "nodes": {+ "type": "array"+ },+ "edges": {+ "type": "array"+ }+ },+ "required": [+ "nodes",+ "edges"+ ]+ },+ "name": {+ "type": "string",+ "description": "Optional new human-readable name for the flow."+ }+ },+ "required": [+ "flow_id"+ ],+ "additionalProperties": false+}diff --git a/crates/openhuman-core/src/flows/builder_tools/persistence.rs b/crates/openhuman-core/src/flows/builder_tools/persistence.rsindex 93ac0103e2..be9673ac09 100644--- a/crates/openhuman-core/src/flows/builder_tools/persistence.rs+++ b/crates/openhuman-core/src/flows/builder_tools/persistence.rs@@ -1,6 +1,7 @@//! Persistence tools: `create_workflow`, `duplicate_flow`, and `save_workflow`.//! Created/duplicated flows are always born DISABLED; save never touches enablement.+use crate::tools::schema_cache::static_schema;use std::sync::Arc;use async_trait::async_trait;@@ -287,34 +288,7 @@ impl Tool for SaveWorkflowTool {}fn parameters_schema(&self) -> Value {- json!({- "type": "object",- "properties": {- "flow_id": {- "type": "string",- "description": "Id of the EXISTING saved flow to write the graph to (the persistence target — always required)."- },- "draft_id": {- "type": "string",- "description": "A working draft whose graph to persist onto the flow. Provide this OR inline `graph`; if both are given, draft_id wins."- },- "graph": {- "type": "object",- "description": "The full tinyflows WorkflowGraph to persist: { name?, nodes: [...], edges: [...] }. Provide this OR `draft_id`. Same shape as propose_workflow.",- "properties": {- "nodes": { "type": "array" },- "edges": { "type": "array" }- },- "required": ["nodes", "edges"]- },- "name": {- "type": "string",- "description": "Optional new human-readable name for the flow."- }- },- "required": ["flow_id"],- "additionalProperties": false- })+ static_schema!(include_str!("parameters/save_workflow.json"))}fn permission_level(&self) -> PermissionLevel {@@ -500,3 +474,7 @@ impl Tool for SaveWorkflowTool {}}}++#[cfg(test)]+#[path = "persistence_schema_tests.rs"]+mod schema_tests;diff --git a/crates/openhuman-core/src/flows/builder_tools/persistence_schema_tests.rs b/crates/openhuman-core/src/flows/builder_tools/persistence_schema_tests.rsnew file mode 100644index 0000000000..11291ce95f--- /dev/null+++ b/crates/openhuman-core/src/flows/builder_tools/persistence_schema_tests.rs@@ -0,0 +1,39 @@+use super::*;+use serde_json::json;++fn expected_save_workflow() -> serde_json::Value {+ json!({+ "type": "object",+ "properties": {+ "flow_id": {+ "type": "string",+ "description": "Id of the EXISTING saved flow to write the graph to (the persistence target — always required)."+ },+ "draft_id": {+ "type": "string",+ "description": "A working draft whose graph to persist onto the flow. Provide this OR inline `graph`; if both are given, draft_id wins."+ },+ "graph": {+ "type": "object",+ "description": "The full tinyflows WorkflowGraph to persist: { name?, nodes: [...], edges: [...] }. Provide this OR `draft_id`. Same shape as propose_workflow.",+ "properties": {+ "nodes": { "type": "array" },+ "edges": { "type": "array" }+ },+ "required": ["nodes", "edges"]+ },+ "name": {+ "type": "string",+ "description": "Optional new human-readable name for the flow."+ }+ },+ "required": ["flow_id"],+ "additionalProperties": false+ })+}++#[test]+fn save_workflow_static_schema_matches_json_literal() {+ let tool = todo!("construct tool");+ assert_eq!(Tool::parameters_schema(&tool), expected_save_workflow());+}diff --git a/crates/openhuman-core/src/flows/discovery_tools.rs b/crates/openhuman-core/src/flows/discovery_tools.rsindex 3079fa0db3..15be6f6767 100644--- a/crates/openhuman-core/src/flows/discovery_tools.rs+++ b/crates/openhuman-core/src/flows/discovery_tools.rs@@ -25,6 +25,7 @@//! designated way to emit its result, analogous to//! [`super::tools::ProposeWorkflowTool`] returning a proposal.+use crate::tools::schema_cache::static_schema;use std::sync::Arc;use async_trait::async_trait;@@ -114,66 +115,7 @@ impl Tool for SuggestWorkflowsTool {}fn parameters_schema(&self) -> Value {- json!({- "type": "object",- "properties": {- "suggestions": {- "type": "array",- "description": "1-8 workflow suggestions, highest-value first.",- "items": {- "type": "object",- "properties": {- "title": {- "type": "string",- "description": "Short, human-friendly title, e.g. \"Auto-file email receipts\"."- },- "one_liner": {- "type": "string",- "description": "One sentence describing what the workflow does."- },- "rationale": {- "type": "string",- "description": "Why this is suggested to THIS user, grounded in what you observed."- },- "trigger_hint": {- "type": "string",- "description": "Likely trigger: \"schedule\" | \"app_event\" | \"manual\" (only these self-fire).",- "enum": ["schedule", "app_event", "manual"]- },- "steps_outline": {- "type": "array",- "items": { "type": "string" },- "description": "Plain-language step outline, one per element."- },- "suggested_connections": {- "type": "array",- "items": { "type": "string" },- "description": "Real connection_ref values from list_flow_connections. Never invented."- },- "suggested_slugs": {- "type": "array",- "items": { "type": "string" },- "description": "Real Composio action slugs from search_tool_catalog. Never hallucinated."- },- "build_prompt": {- "type": "string",- "description": "Self-contained natural-language brief handed to the workflow-builder on \"Build this\"."- },- "confidence": {- "type": "number",- "description": "Your confidence in [0,1] that this is a genuinely useful, buildable automation."- }- },- "required": ["title", "one_liner", "rationale", "build_prompt"]- }- },- "run_id": {- "type": "string",- "description": "Optional correlation id for the discovery run that produced these."- }- },- "required": ["suggestions"]- })+ static_schema!(include_str!("parameters/suggest_workflows.json"))}fn permission_level(&self) -> PermissionLevel {@@ -291,3 +233,7 @@ impl Tool for SuggestWorkflowsTool {#[cfg(test)]#[path = "discovery_tools_tests.rs"]mod tests;++#[cfg(test)]+#[path = "discovery_tools_schema_tests.rs"]+mod schema_tests;diff --git a/crates/openhuman-core/src/flows/discovery_tools_schema_tests.rs b/crates/openhuman-core/src/flows/discovery_tools_schema_tests.rsnew file mode 100644index 0000000000..0a016a2f3c--- /dev/null+++ b/crates/openhuman-core/src/flows/discovery_tools_schema_tests.rs@@ -0,0 +1,71 @@+use super::*;+use serde_json::json;++fn expected_suggest_workflows() -> serde_json::Value {+ json!({+ "type": "object",+ "properties": {+ "suggestions": {+ "type": "array",+ "description": "1-8 workflow suggestions, highest-value first.",+ "items": {+ "type": "object",+ "properties": {+ "title": {+ "type": "string",+ "description": "Short, human-friendly title, e.g. \"Auto-file email receipts\"."+ },+ "one_liner": {+ "type": "string",+ "description": "One sentence describing what the workflow does."+ },+ "rationale": {+ "type": "string",+ "description": "Why this is suggested to THIS user, grounded in what you observed."+ },+ "trigger_hint": {+ "type": "string",+ "description": "Likely trigger: \"schedule\" | \"app_event\" | \"manual\" (only these self-fire).",+ "enum": ["schedule", "app_event", "manual"]+ },+ "steps_outline": {+ "type": "array",+ "items": { "type": "string" },+ "description": "Plain-language step outline, one per element."+ },+ "suggested_connections": {+ "type": "array",+ "items": { "type": "string" },+ "description": "Real connection_ref values from list_flow_connections. Never invented."+ },+ "suggested_slugs": {+ "type": "array",+ "items": { "type": "string" },+ "description": "Real Composio action slugs from search_tool_catalog. Never hallucinated."+ },+ "build_prompt": {+ "type": "string",+ "description": "Self-contained natural-language brief handed to the workflow-builder on \"Build this\"."+ },+ "confidence": {+ "type": "number",+ "description": "Your confidence in [0,1] that this is a genuinely useful, buildable automation."+ }+ },+ "required": ["title", "one_liner", "rationale", "build_prompt"]+ }+ },+ "run_id": {+ "type": "string",+ "description": "Optional correlation id for the discovery run that produced these."+ }+ },+ "required": ["suggestions"]+ })+}++#[test]+fn suggest_workflows_static_schema_matches_json_literal() {+ let tool = todo!("construct tool");+ assert_eq!(Tool::parameters_schema(&tool), expected_suggest_workflows());+}diff --git a/crates/openhuman-core/src/flows/memory_tools.rs b/crates/openhuman-core/src/flows/memory_tools.rsindex 4112b1f911..68bd4d24b6 100644--- a/crates/openhuman-core/src/flows/memory_tools.rs+++ b/crates/openhuman-core/src/flows/memory_tools.rs@@ -22,6 +22,7 @@//! [`FlowMemoryRecallTool`] only ever reads with a flow tag filter//! (`flow:<id>` or `flows`), so it never reaches the user's own memory.+use crate::tools::schema_cache::static_schema;use std::sync::Arc;use async_trait::async_trait;@@ -419,31 +420,7 @@ impl Tool for FlowMemoryRememberTool {}fn parameters_schema(&self) -> serde_json::Value {- json!({- "type": "object",- "properties": {- "flow_id": {- "type": "string",- "description": "Informational only: inside a running flow the active flow's own id \- (from the run's trusted origin) is authoritative and this value is ignored. This \- tool ONLY works inside a workflow run — calling it from chat or any other context \- without a trusted run origin is refused, regardless of what is passed here."- },- "key": {- "type": "string",- "description": "Unique key for this memory within the flow's own memory"- },- "content": {- "type": "string",- "description": "The information to remember"- },- "category": {- "type": "string",- "description": "What kind of statement this is: 'fact' (default), 'preference', 'procedure', 'correction', or anything else (stored as 'other')."- }- },- "required": ["flow_id", "key", "content"]- })+ static_schema!(include_str!("parameters/flow_memory_remember.json"))}fn permission_level(&self) -> PermissionLevel {@@ -522,3 +499,7 @@ impl Tool for FlowMemoryRememberTool {#[cfg(test)]#[path = "memory_tools_tests.rs"]mod tests;++#[cfg(test)]+#[path = "memory_tools_schema_tests.rs"]+mod schema_tests;diff --git a/crates/openhuman-core/src/flows/memory_tools_schema_tests.rs b/crates/openhuman-core/src/flows/memory_tools_schema_tests.rsnew file mode 100644index 0000000000..21e0df4c32--- /dev/null+++ b/crates/openhuman-core/src/flows/memory_tools_schema_tests.rs@@ -0,0 +1,36 @@+use super::*;+use serde_json::json;++fn expected_flow_memory_remember() -> serde_json::Value {+ json!({+ "type": "object",+ "properties": {+ "flow_id": {+ "type": "string",+ "description": "Informational only: inside a running flow the active flow's own id \+ (from the run's trusted origin) is authoritative and this value is ignored. This \+ tool ONLY works inside a workflow run — calling it from chat or any other context \+ without a trusted run origin is refused, regardless of what is passed here."+ },+ "key": {+ "type": "string",+ "description": "Unique key for this memory within the flow's own memory"+ },+ "content": {+ "type": "string",+ "description": "The information to remember"+ },+ "category": {+ "type": "string",+ "description": "What kind of statement this is: 'fact' (default), 'preference', 'procedure', 'correction', or anything else (stored as 'other')."+ }+ },+ "required": ["flow_id", "key", "content"]+ })+}++#[test]+fn flow_memory_remember_static_schema_matches_json_literal() {+ let tool = todo!("construct tool");+ assert_eq!(Tool::parameters_schema(&tool), expected_flow_memory_remember());+}diff --git a/crates/openhuman-core/src/flows/parameters/flow_memory_remember.json b/crates/openhuman-core/src/flows/parameters/flow_memory_remember.jsonnew file mode 100644index 0000000000..ca0fc1707d--- /dev/null+++ b/crates/openhuman-core/src/flows/parameters/flow_memory_remember.json@@ -0,0 +1,26 @@+{+ "type": "object",+ "properties": {+ "flow_id": {+ "type": "string",+ "description": "Informational only: inside a running flow the active flow's own id (from the run's trusted origin) is authoritative and this value is ignored. This tool ONLY works inside a workflow run — calling it from chat or any other context without a trusted run origin is refused, regardless of what is passed here."+ },+ "key": {+ "type": "string",+ "description": "Unique key for this memory within the flow's own memory"+ },+ "content": {+ "type": "string",+ "description": "The information to remember"+ },+ "category": {+ "type": "string",+ "description": "What kind of statement this is: 'fact' (default), 'preference', 'procedure', 'correction', or anything else (stored as 'other')."+ }+ },+ "required": [+ "flow_id",+ "key",+ "content"+ ]+}diff --git a/crates/openhuman-core/src/flows/parameters/suggest_workflows.json b/crates/openhuman-core/src/flows/parameters/suggest_workflows.jsonnew file mode 100644index 0000000000..4d605b8a03--- /dev/null+++ b/crates/openhuman-core/src/flows/parameters/suggest_workflows.json@@ -0,0 +1,77 @@+{+ "type": "object",+ "properties": {+ "suggestions": {+ "type": "array",+ "description": "1-8 workflow suggestions, highest-value first.",+ "items": {+ "type": "object",+ "properties": {+ "title": {+ "type": "string",+ "description": "Short, human-friendly title, e.g. \"Auto-file email receipts\"."+ },+ "one_liner": {+ "type": "string",+ "description": "One sentence describing what the workflow does."+ },+ "rationale": {+ "type": "string",+ "description": "Why this is suggested to THIS user, grounded in what you observed."+ },+ "trigger_hint": {+ "type": "string",+ "description": "Likely trigger: \"schedule\" | \"app_event\" | \"manual\" (only these self-fire).",+ "enum": [+ "schedule",+ "app_event",+ "manual"+ ]+ },+ "steps_outline": {+ "type": "array",+ "items": {+ "type": "string"+ },+ "description": "Plain-language step outline, one per element."+ },+ "suggested_connections": {+ "type": "array",+ "items": {+ "type": "string"+ },+ "description": "Real connection_ref values from list_flow_connections. Never invented."+ },+ "suggested_slugs": {+ "type": "array",+ "items": {+ "type": "string"+ },+ "description": "Real Composio action slugs from search_tool_catalog. Never hallucinated."+ },+ "build_prompt": {+ "type": "string",+ "description": "Self-contained natural-language brief handed to the workflow-builder on \"Build this\"."+ },+ "confidence": {+ "type": "number",+ "description": "Your confidence in [0,1] that this is a genuinely useful, buildable automation."+ }+ },+ "required": [+ "title",+ "one_liner",+ "rationale",+ "build_prompt"+ ]+ }+ },+ "run_id": {+ "type": "string",+ "description": "Optional correlation id for the discovery run that produced these."+ }+ },+ "required": [+ "suggestions"+ ]+}diff --git a/crates/openhuman-core/src/tools/mod.rs b/crates/openhuman-core/src/tools/mod.rsindex acfcf9e033..d1dfb677ea 100644--- a/crates/openhuman-core/src/tools/mod.rs+++ b/crates/openhuman-core/src/tools/mod.rs@@ -3,6 +3,7 @@ pub mod host_extensions;pub mod ops;pub mod orchestrator_tools;pub mod registry;+pub(crate) mod schema_cache;mod schemas;pub mod status;pub mod timeout;diff --git a/crates/openhuman-core/src/tools/schema_cache.rs b/crates/openhuman-core/src/tools/schema_cache.rsnew file mode 100644index 0000000000..622336f8a3--- /dev/null+++ b/crates/openhuman-core/src/tools/schema_cache.rs@@ -0,0 +1,41 @@+//! Static, parse-once parameter schemas for agent tools.+//!+//! A tool whose `parameters_schema` is constant keeps the schema as a JSON+//! file next to its module and returns it through [`static_schema!`] instead+//! of rebuilding a large `json!` literal on every call. The file is embedded+//! with `include_str!`, parsed once into a `LazyLock<Value>`, and each call+//! returns a clone.++use serde_json::Value;++/// Parse an embedded schema. Panics with the call site on malformed JSON;+/// every converted tool has a test that forces its static, so a bad file+/// fails in CI rather than at runtime.+pub(crate) fn parse_embedded(site: &str, src: &str) -> Value {+ match serde_json::from_str(src) {+ Ok(value) => value,+ Err(error) => panic!("embedded tool schema at {site} is not valid JSON: {error}"),+ }+}++/// Return a constant tool schema parsed once from an embedded JSON string.+///+/// ```ignore+/// fn parameters_schema(&self) -> Value {+/// static_schema!(include_str!("parameters/my_tool.json"))+/// }+/// ```+macro_rules! static_schema {+ ($src:expr) => {{+ static SCHEMA: ::std::sync::LazyLock<::serde_json::Value> =+ ::std::sync::LazyLock::new(|| {+ $crate::tools::schema_cache::parse_embedded(+ concat!(file!(), ":", line!()),+ $src,+ )+ });+ ::std::clone::Clone::clone(&*SCHEMA)+ }};+}++pub(crate) use static_schema;