Skip to content

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

refactor(agent): source flow agent prompts from TinyFlows Copilot

Steven Enamakelf3dbefa751d0
diff --git a/crates/openhuman-core/src/agent/registry/agents/flow_discovery/prompt.rs b/crates/openhuman-core/src/agent/registry/agents/flow_discovery/prompt.rs
index b26d9c4e3f..0e2c0aa91a 100644
--- a/crates/openhuman-core/src/agent/registry/agents/flow_discovery/prompt.rs
+++ b/crates/openhuman-core/src/agent/registry/agents/flow_discovery/prompt.rs
@@ -1,36 +1,18 @@
//! System prompt builder for the `flow_discovery` built-in agent (the "Flow
//! Scout").
//!
-//! Assembles the discovery archetype (from the sibling `prompt.md`) plus the
-//! shared runtime sections (the agent's tool list and the workspace footer).
-//! No `## Safety` block: `omit_safety_preamble = true` because every tool in
-//! scope is read-only except the `suggest_workflows` emit sink (which has no
-//! external effect); the "read, then suggest — never act" invariant lives in
-//! the archetype body instead.
+//! Composes the module-owned discovery archetype with OpenHuman's scoped
+//! runtime sections. The caller fetches the archetype through TinyFlows Copilot
+//! before invoking this synchronous builder.
-use crate::agent::prompts::{render_tools, render_workspace, PromptContext};
-use anyhow::Result;
-
-const ARCHETYPE: &str = tinyflows_copilot::prompts::FLOW_DISCOVERY;
+use crate::agent::prompts::PromptContext;
+use anyhow::{anyhow, Result};
pub fn build(ctx: &PromptContext<'_>) -> Result<String> {
- let mut out = String::with_capacity(8192);
- out.push_str(ARCHETYPE.trim_end());
- out.push_str("\n\n");
-
- let tools = render_tools(ctx)?;
- if !tools.trim().is_empty() {
- out.push_str(tools.trim_end());
- out.push_str("\n\n");
- }
-
- let workspace = render_workspace(ctx)?;
- if !workspace.trim().is_empty() {
- out.push_str(workspace.trim_end());
- out.push('\n');
- }
-
- Ok(out)
+ let archetype = ctx.flow_archetype_text.ok_or_else(|| {
+ anyhow!("flow_discovery requires a scoped TinyFlows GetPrompt response")
+ })?;
+ super::super::flow_prompts::build_with_archetype(ctx, archetype)
}
#[cfg(test)]
diff --git a/crates/openhuman-core/src/agent/registry/agents/flow_discovery/prompt_tests.rs b/crates/openhuman-core/src/agent/registry/agents/flow_discovery/prompt_tests.rs
index ced8ef588d..cb3f586b36 100644
--- a/crates/openhuman-core/src/agent/registry/agents/flow_discovery/prompt_tests.rs
+++ b/crates/openhuman-core/src/agent/registry/agents/flow_discovery/prompt_tests.rs
@@ -1,14 +1,15 @@
use super::*;
-use std::collections::HashSet;
-use tinytools_agent::dialect::ToolCallFormat;
-fn ctx() -> PromptContext<'static> {
- static VISIBLE: std::sync::OnceLock<HashSet<String>> = std::sync::OnceLock::new();
- let visible = VISIBLE.get_or_init(HashSet::new);
+fn ctx<'a>(
+ workspace: &'a std::path::Path,
+ visible: &'a std::collections::HashSet<String>,
+ archetype: Option<&'a str>,
+) -> PromptContext<'a> {
PromptContext {
- workspace_dir: std::path::Path::new("."),
+ workspace_dir: workspace,
model_name: "test",
agent_id: "flow_discovery",
+ flow_archetype_text: archetype,
tools: &[],
workflows: &[],
dispatcher_instructions: "",
@@ -23,9 +24,24 @@ fn ctx() -> PromptContext<'static> {
}
}
-#[test]
-fn prompt_teaches_the_read_only_emit_invariant() {
- let body = build(&ctx()).unwrap();
+#[tokio::test]
+async fn module_prompt_teaches_the_read_only_emit_invariant() {
+ let workspace = tempfile::tempdir().expect("workspace");
+ let config = crate::config::Config {
+ workspace_dir: workspace.path().to_path_buf(),
+ ..crate::config::Config::default()
+ };
+ let registry = crate::agent::harness::host_definition::AgentDefinitionRegistry::builtins_only();
+ let definition = registry.get("flow_discovery").expect("flow_discovery builtin");
+ let archetype = crate::agent::prompts::flow_archetype::load_for_definition(
+ Some(&config),
+ definition,
+ )
+ .await
+ .expect("TinyFlows GetPrompt succeeds")
+ .expect("flow builtin prompt");
+ let body = build(&ctx(workspace.path(), &std::collections::HashSet::new(), Some(&archetype)))
+ .expect("compose module prompt");
let lc = body.to_lowercase();
assert!(lc.contains("suggest_workflows"), "must name the emit tool");
assert!(
@@ -33,3 +49,15 @@ fn prompt_teaches_the_read_only_emit_invariant() {
"prompt must teach the read-only invariant"
);
}
+
+#[test]
+fn flow_discovery_requires_an_explicit_archetype_override() {
+ let workspace = tempfile::tempdir().expect("workspace");
+ let error = build(&ctx(
+ workspace.path(),
+ &std::collections::HashSet::new(),
+ None,
+ ))
+ .expect_err("no static or host fallback is allowed");
+ assert!(error.to_string().contains("GetPrompt"));
+}
diff --git a/crates/openhuman-core/src/agent/registry/agents/loader.rs b/crates/openhuman-core/src/agent/registry/agents/loader.rs
index 5f62e5b939..221451b278 100644
--- a/crates/openhuman-core/src/agent/registry/agents/loader.rs
+++ b/crates/openhuman-core/src/agent/registry/agents/loader.rs
@@ -137,8 +137,8 @@ pub const BUILTINS: &[BuiltinAgent] = &[
#[cfg(feature = "flows")]
BuiltinAgent {
id: "workflow_builder",
- toml: include_str!("../../../flows/agents/workflow_builder/agent.toml"),
- prompt_fn: crate::flows::agents::workflow_builder::prompt::build,
+ toml: include_str!("workflow_builder/agent.toml"),
+ prompt_fn: super::workflow_builder::prompt::build,
},
// Workflow-discovery specialist (the "Flow Scout"): reads the user's
// memory/threads/people/connections/flows read-only and ends by calling
@@ -150,8 +150,8 @@ pub const BUILTINS: &[BuiltinAgent] = &[
#[cfg(feature = "flows")]
BuiltinAgent {
id: "flow_discovery",
- toml: include_str!("../../../flows/agents/flow_discovery/agent.toml"),
- prompt_fn: crate::flows::agents::flow_discovery::prompt::build,
+ toml: include_str!("flow_discovery/agent.toml"),
+ prompt_fn: super::flow_discovery::prompt::build,
},
];
diff --git a/crates/openhuman-core/src/agent/registry/agents/workflow_builder/prompt.rs b/crates/openhuman-core/src/agent/registry/agents/workflow_builder/prompt.rs
index c063eaf1c0..e8b7610eb6 100644
--- a/crates/openhuman-core/src/agent/registry/agents/workflow_builder/prompt.rs
+++ b/crates/openhuman-core/src/agent/registry/agents/workflow_builder/prompt.rs
@@ -1,33 +1,15 @@
//! System prompt builder for the `workflow_builder` built-in agent (Phase 5a).
//!
-//! Assembles the workflow-authoring archetype (`tinyflows_copilot::prompts::WORKFLOW_BUILDER`
-//! — it belongs to the engine, not to this host) plus the shared runtime sections (the agent's tool list and the
-//! workspace footer). No `## Safety` block — the agent has `omit_safety_preamble
-//! = true` in its TOML because every tool in scope is propose-or-read and has no
-//! real external effect (the "propose, never persist" invariant lives in the
-//! archetype body instead).
+//! Composes the module-owned archetype text with OpenHuman's scoped runtime
+//! sections. The caller fetches the archetype through TinyFlows Copilot before
+//! invoking this synchronous builder.
-use crate::agent::prompts::{render_tools, render_workspace, PromptContext};
-use anyhow::Result;
-
-const ARCHETYPE: &str = tinyflows_copilot::prompts::WORKFLOW_BUILDER;
+use crate::agent::prompts::PromptContext;
+use anyhow::{anyhow, Result};
pub fn build(ctx: &PromptContext<'_>) -> Result<String> {
- let mut out = String::with_capacity(8192);
- out.push_str(ARCHETYPE.trim_end());
- out.push_str("\n\n");
-
- let tools = render_tools(ctx)?;
- if !tools.trim().is_empty() {
- out.push_str(tools.trim_end());
- out.push_str("\n\n");
- }
-
- let workspace = render_workspace(ctx)?;
- if !workspace.trim().is_empty() {
- out.push_str(workspace.trim_end());
- out.push('\n');
- }
-
- Ok(out)
+ let archetype = ctx.flow_archetype_text.ok_or_else(|| {
+ anyhow!("workflow_builder requires a scoped TinyFlows GetPrompt response")
+ })?;
+ super::super::flow_prompts::build_with_archetype(ctx, archetype)
}
diff --git a/crates/openhuman-core/src/flows/mod.rs b/crates/openhuman-core/src/flows/mod.rs
index b4051a20cd..d0168f54af 100644
--- a/crates/openhuman-core/src/flows/mod.rs
+++ b/crates/openhuman-core/src/flows/mod.rs
@@ -24,7 +24,6 @@
//! family must convert to the facade+stub shape (see `voice/`).
mod agent_route;
-pub mod agents;
pub mod builder_host;
pub(crate) mod builder_tools;
mod builder_tools_connection_reads;