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
refactor(subagent_host): fold flow prompt loading into typed prompt source
Steven Enamakel77f452239d63
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rsindex 1809277e76..9b5741d374 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs@@ -43,7 +43,7 @@ use super::provider::{resolve_subagent_source, user_is_signed_in_to_composio};#[path = "runner_prompt.rs"]mod runner_prompt;-use runner_prompt::{load_flow_prompt, load_typed_prompt_source, LoadedConfig};+use runner_prompt::{load_typed_prompt_source, LoadedConfig};/// Runtime spawn-hierarchy gate decision for one delegation hop.///@@ -289,7 +289,6 @@ pub(crate) async fn run_subagent_direct(.await.map(std::sync::Arc::new).map_err(|e| e.to_string());- let flow_archetype_text: Option<String> = None; // controlled stack comparisontracing::info!(agent_id = %definition.id,@@ -336,7 +335,6 @@ pub(crate) async fn run_subagent_direct(&parent_for_subagent,&task_id,&loaded_config,- flow_archetype_text.as_deref(),)).await})@@ -551,7 +549,6 @@ async fn run_typed_mode(parent: &ParentExecutionContext,task_id: &str,config: &LoadedConfig,- flow_archetype_text: Option<&str>,) -> Result<SubagentRunOutcome, SubagentRunError> {let started = Instant::now();@@ -770,8 +767,7 @@ async fn run_typed_mode(agents_md_local: agents_md.local.clone(),};- let archetype_prompt_body =- load_typed_prompt_source(definition, prompt_ctx, flow_archetype_text)?;+ let archetype_prompt_body = load_typed_prompt_source(definition, config, prompt_ctx).await?;let system_prompt = match &definition.system_prompt {// The whole prompt, with no sub-agent sections around it.PromptSource::Dynamic(_) | PromptSource::Verbatim(_) => archetype_prompt_body,diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner_flow_prompt_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner_flow_prompt_tests.rsindex af0642074e..b3140ff5e7 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner_flow_prompt_tests.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner_flow_prompt_tests.rs@@ -42,11 +42,9 @@ async fn typed_subagent_prompts_use_scoped_bus_text_for_both_flow_builtins() {let definition = registry.get(agent_id).expect("flow builtin");let context = prompt_context(temp.path(), agent_id);let loaded_config = Ok(std::sync::Arc::clone(&config));- let archetype = load_flow_prompt(definition, &loaded_config)+ let body = load_typed_prompt_source(definition, &loaded_config, context).await.unwrap_or_else(|error| panic!("loading {agent_id} prompt: {error}"));- let body = load_typed_prompt_source(definition, context, archetype.as_deref())- .unwrap_or_else(|error| panic!("rendering {agent_id} prompt: {error}"));assert!(body.contains(expected_tool),"{agent_id} prompt missing its tool"@@ -63,8 +61,9 @@ async fn typed_flow_builtin_requires_its_loaded_config() {.get("workflow_builder").expect("workflow_builder builtin");let temp = tempfile::tempdir().expect("workspace");+ let context = prompt_context(temp.path(), "workflow_builder");let loaded_config = Err("config unavailable".into());- let error = load_flow_prompt(definition, &loaded_config)+ let error = load_typed_prompt_source(definition, &loaded_config, context).await.expect_err("bus-backed prompt must not use ambient config");assert!(error.to_string().contains("scoped runtime config"));@@ -86,10 +85,8 @@ async fn typed_static_prompt_override_skips_tinyflows_even_when_disabled() {let context = prompt_context(temp.path(), "workflow_builder");let loaded_config = Ok(config);- let archetype = load_flow_prompt(&definition, &loaded_config)+ let body = load_typed_prompt_source(&definition, &loaded_config, context).await.expect("static prompt override does not access the module");- let body = load_typed_prompt_source(&definition, context, archetype.as_deref())- .expect("static prompt renders synchronously");assert_eq!(body, "session-owned prompt");}diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner_prompt.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner_prompt.rsindex 6bda8204bb..bb91325e9d 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner_prompt.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner_prompt.rs@@ -9,32 +9,21 @@ use crate::agent::subagent_host::tool_prep::load_prompt_source;/// on the same profile snapshot without giving the generic runtime file access.pub(super) type LoadedConfig = Result<std::sync::Arc<crate::config::Config>, String>;-/// Prefetch a module-owned archetype before entering the large typed-runner future.-pub(super) async fn load_flow_prompt(+/// Load and render a typed sub-agent prompt using this spawn's config snapshot.+pub(super) async fn load_typed_prompt_source(definition: &AgentDefinition,- config: &LoadedConfig,-) -> Result<Option<String>, SubagentRunError> {+ _config: &LoadedConfig,+ mut prompt_context: PromptContext<'_>,+) -> Result<String, SubagentRunError> {#[cfg(feature = "flows")]- {- return Ok(crate::agent::prompts::flow_archetype::load_for_definition(- config.as_ref().ok().map(|config| config.as_ref()),- definition,- )- .await?);- }+ let flow_archetype_text = crate::agent::prompts::flow_archetype::load_for_definition(+ _config.as_ref().ok().map(|config| config.as_ref()),+ definition,+ )+ .await?;#[cfg(not(feature = "flows"))]- {- let _ = (definition, config);- Ok(None)- }-}+ let flow_archetype_text: Option<String> = None;-/// Synchronously render a typed prompt with the already scoped module text.-pub(super) fn load_typed_prompt_source<'a>(- definition: &AgentDefinition,- mut prompt_context: PromptContext<'a>,- flow_archetype_text: Option<&'a str>,-) -> Result<String, SubagentRunError> {- prompt_context.flow_archetype_text = flow_archetype_text;+ prompt_context.flow_archetype_text = flow_archetype_text.as_deref();load_prompt_source(definition, &prompt_context)}