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): split flow archetype loading from prompt rendering
Steven Enamakelb57faf39515a
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rsindex e429c9f3d7..babea914be 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_typed_prompt_source, LoadedConfig};+use runner_prompt::{load_flow_prompt, load_typed_prompt_source, LoadedConfig};/// Runtime spawn-hierarchy gate decision for one delegation hop.///@@ -289,6 +289,7 @@ pub(crate) async fn run_subagent_direct(.await.map(std::sync::Arc::new).map_err(|e| e.to_string());+ let flow_archetype_text = Box::pin(load_flow_prompt(definition, &loaded_config)).await?;tracing::info!(agent_id = %definition.id,@@ -335,6 +336,7 @@ pub(crate) async fn run_subagent_direct(&parent_for_subagent,&task_id,&loaded_config,+ flow_archetype_text,)).await})@@ -549,6 +551,7 @@ async fn run_typed_mode(parent: &ParentExecutionContext,task_id: &str,config: &LoadedConfig,+ flow_archetype_text: Option<String>,) -> Result<SubagentRunOutcome, SubagentRunError> {let started = Instant::now();@@ -767,8 +770,11 @@ async fn run_typed_mode(agents_md_local: agents_md.local.clone(),};- let archetype_prompt_body =- Box::pin(load_typed_prompt_source(definition, config, prompt_ctx)).await?;+ let archetype_prompt_body = load_typed_prompt_source(+ definition,+ prompt_ctx,+ flow_archetype_text.as_deref(),+ )?;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_prompt.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner_prompt.rsindex bb91325e9d..d92cb5d285 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,21 +9,32 @@ 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>;-/// Load and render a typed sub-agent prompt using this spawn's config snapshot.-pub(super) async fn load_typed_prompt_source(+/// Prefetch a module-owned archetype before entering the large typed-runner future.+pub(super) async fn load_flow_prompt(definition: &AgentDefinition,- _config: &LoadedConfig,- mut prompt_context: PromptContext<'_>,-) -> Result<String, SubagentRunError> {+ config: &LoadedConfig,+) -> Result<Option<String>, SubagentRunError> {#[cfg(feature = "flows")]- let flow_archetype_text = crate::agent::prompts::flow_archetype::load_for_definition(- _config.as_ref().ok().map(|config| config.as_ref()),- definition,- )- .await?;+ {+ return Ok(crate::agent::prompts::flow_archetype::load_for_definition(+ config.as_ref().ok().map(|config| config.as_ref()),+ definition,+ )+ .await?);+ }#[cfg(not(feature = "flows"))]- let flow_archetype_text: Option<String> = None;+ {+ let _ = (definition, config);+ Ok(None)+ }+}- prompt_context.flow_archetype_text = flow_archetype_text.as_deref();+/// Synchronously render a typed prompt with the already scoped module text.+pub(super) fn load_typed_prompt_source(+ definition: &AgentDefinition,+ mut prompt_context: PromptContext<'_>,+ flow_archetype_text: Option<&str>,+) -> Result<String, SubagentRunError> {+ prompt_context.flow_archetype_text = flow_archetype_text;load_prompt_source(definition, &prompt_context)}