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
chore: files changed crates/openhuman-core/src/agent/registry/agents/fleet_prompt_tests.rs
Steven Enamakel4f83b23f5456
diff --git a/crates/openhuman-core/src/agent/registry/agents/fleet_prompt_tests.rs b/crates/openhuman-core/src/agent/registry/agents/fleet_prompt_tests.rsindex 79dc9ec4d4..e9da23346b 100644--- a/crates/openhuman-core/src/agent/registry/agents/fleet_prompt_tests.rs+++ b/crates/openhuman-core/src/agent/registry/agents/fleet_prompt_tests.rs@@ -8,7 +8,7 @@use super::load_builtins;use crate::agent::harness::host_definition::AgentDefinition;use crate::agent::prompts::PromptContext;-use std::collections::{BTreeMap, BTreeSet, HashSet};+use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};use std::sync::Arc;use tinyagents_definition::{PromptSource, SubagentEntry, ToolScope};use tinytools_agent::dialect::ToolCallFormat;@@ -48,7 +48,11 @@ fn visible_tool_names(def: &AgentDefinition, definitions: &[AgentDefinition]) ->visible}-fn render(def: &AgentDefinition, definitions: &[AgentDefinition]) -> String {+fn render(+ def: &AgentDefinition,+ definitions: &[AgentDefinition],+ flow_prompts: &HashMap<String, String>,+) -> String {let (PromptSource::Dynamic(()), Some(build)) =(&def.system_prompt, def.extensions.prompt_builder)else {@@ -60,8 +64,7 @@ fn render(def: &AgentDefinition, definitions: &[AgentDefinition]) -> String {workspace_dir: workspace.path(),model_name: "test",agent_id: &def.id,- flow_archetype_text: matches!(def.id.as_str(), "workflow_builder" | "flow_discovery")- .then_some("synthetic flow archetype for registry coverage"),+ flow_archetype_text: flow_prompts.get(&def.id).map(String::as_str),tools: &[],workflows: &[],dispatcher_instructions: "",@@ -83,6 +86,34 @@ fn render(def: &AgentDefinition, definitions: &[AgentDefinition]) -> String {body}+async fn flow_prompt_texts(definitions: &[AgentDefinition]) -> HashMap<String, String> {+ #[cfg(feature = "flows")]+ {+ let temp = tempfile::TempDir::new().expect("flow prompt workspace");+ let config = crate::config::Config {+ workspace_dir: temp.path().join("workspace"),+ action_dir: temp.path().join("action"),+ config_path: temp.path().join("config.toml"),+ ..crate::config::Config::default()+ };+ let mut prompts = HashMap::new();+ for agent_id in ["workflow_builder", "flow_discovery"] {+ if definitions.iter().any(|definition| definition.id == agent_id) {+ let text = crate::agent::prompts::flow_archetype::fetch_prompt(&config, agent_id)+ .await+ .unwrap_or_else(|error| panic!("fetching `{agent_id}` prompt: {error}"));+ prompts.insert(agent_id.to_owned(), text);+ }+ }+ prompts+ }+ #[cfg(not(feature = "flows"))]+ {+ let _ = definitions;+ HashMap::new()+ }+}+/// Every tool name the process can register, plus every packed name (some of/// which are synthesised hand-offs that no registry lists).///@@ -215,9 +246,11 @@ pub(super) fn names_presented_as_callable<'a>(/// or a prompt that drops the `tool_search` hint, fails here instead of/// leaving a stale excuse in [`KNOWN_UNCALLABLE`].#[test]-fn deferred_rows_name_deferred_tools_the_prompt_routes_through_tool_search() {+#[tokio::test]+async fn deferred_rows_name_deferred_tools_the_prompt_routes_through_tool_search() {let tools = registered_tools();let defs = load_builtins().expect("built-ins load");+ let flow_prompts = flow_prompt_texts(&defs).await;let deferred = KNOWN_UNCALLABLE.iter().filter(|(_, _, why)| why.starts_with("`ToolExposure::Deferred`"));@@ -235,7 +268,7 @@ fn deferred_rows_name_deferred_tools_the_prompt_routes_through_tool_search() {.iter().find(|d| d.id == *agent).unwrap_or_else(|| panic!("Deferred row names unknown agent `{agent}`"));- let prompt = render(def, &defs);+ let prompt = render(def, &defs, &flow_prompts);assert!(prompt.contains("`tool_search`") && prompt.contains(&format!("`{tool}`")),"`{agent}`'s prompt must name `{tool}` with its route, `tool_search`"@@ -293,8 +326,8 @@ const KNOWN_UNCALLABLE: &[(&str, &str, &str)] = &[/// so the prompt taught a call the model could not make: it emits the name,/// the harness answers "unknown tool", and the iteration is spent. This is/// that rule over every built-in, against each one's own callable surface.-#[test]-fn every_prompt_names_only_tools_its_agent_can_call() {+#[tokio::test]+async fn every_prompt_names_only_tools_its_agent_can_call() {let universe = tool_universe();let known = |agent: &str, tool: &str| {KNOWN_UNCALLABLE@@ -302,6 +335,7 @@ fn every_prompt_names_only_tools_its_agent_can_call() {.any(|(a, t, _)| (*a == "*" || *a == agent) && *t == tool)};let defs = load_builtins().expect("built-ins load");+ let flow_prompts = flow_prompt_texts(&defs).await;// A feature-gated agent absent from this build cannot fire its rows.let loaded: HashSet<&str> = defs.iter().map(|d| d.id.as_str()).collect();let mut fired = HashSet::new();@@ -311,7 +345,7 @@ fn every_prompt_names_only_tools_its_agent_can_call() {.iter().map(String::as_str).filter(|name| !can_call(def, name, &universe));- for tool in names_presented_as_callable(&render(def, &defs), not_callable) {+ for tool in names_presented_as_callable(&render(def, &defs, &flow_prompts), not_callable) {if known(&def.id, tool) {fired.insert((def.id.clone(), tool));} else {@@ -419,10 +453,11 @@ fn profile_note(missing: &BTreeMap<String, Vec<String>>) -> String {)}-#[test]-fn every_prompt_names_at_least_one_tool_it_can_call() {+#[tokio::test]+async fn every_prompt_names_at_least_one_tool_it_can_call() {let universe = tool_universe();let defs = load_builtins().expect("built-ins load");+ let flow_prompts = flow_prompt_texts(&defs).await;let expected: Vec<&str> = NAMES_NO_TOOL.iter().copied()@@ -433,7 +468,7 @@ fn every_prompt_names_at_least_one_tool_it_can_call() {.iter().filter(|def| !matches!(&def.tools, ToolScope::Named(n) if n.is_empty())).filter(|def| {- let prompt = render(def, &defs);+ let prompt = render(def, &defs, &flow_prompts);!universe.iter().any(|name| can_call(def, name, &universe) && prompt.contains(&format!("`{name}`")))@@ -447,7 +482,8 @@ fn every_prompt_names_at_least_one_tool_it_can_call() {.filter(|id| !expected.contains(&id.as_str())).filter_map(|id| {let def = defs.iter().find(|d| &d.id == id)?;- let absent = belt_tools_absent_from_build(def, &render(def, &defs), &universe);+ let absent =+ belt_tools_absent_from_build(def, &render(def, &defs, &flow_prompts), &universe);(!absent.is_empty()).then(|| (id.clone(), absent))}).collect();