Skip to content

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

refactor(subagent_host): split flow prompt loading from typed prompt rendering

Steven Enamakel188a5bcb659a
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.rs
index b3140ff5e7..ca13b4fb98 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,9 +42,11 @@ 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 body = load_typed_prompt_source(definition, &loaded_config, context)
+ let archetype = load_flow_prompt(definition, &loaded_config)
.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,7 +65,7 @@ async fn typed_flow_builtin_requires_its_loaded_config() {
let temp = tempfile::tempdir().expect("workspace");
let context = prompt_context(temp.path(), "workflow_builder");
let loaded_config = Err("config unavailable".into());
- let error = load_typed_prompt_source(definition, &loaded_config, context)
+ let error = load_flow_prompt(definition, &loaded_config)
.await
.expect_err("bus-backed prompt must not use ambient config");
assert!(error.to_string().contains("scoped runtime config"));
@@ -85,8 +87,10 @@ 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 body = load_typed_prompt_source(&definition, &loaded_config, context)
+ let archetype = load_flow_prompt(&definition, &loaded_config)
.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.rs
index d92cb5d285..6bda8204bb 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
@@ -30,10 +30,10 @@ pub(super) async fn load_flow_prompt(
}
/// Synchronously render a typed prompt with the already scoped module text.
-pub(super) fn load_typed_prompt_source(
+pub(super) fn load_typed_prompt_source<'a>(
definition: &AgentDefinition,
- mut prompt_context: PromptContext<'_>,
- flow_archetype_text: Option<&str>,
+ mut prompt_context: PromptContext<'a>,
+ flow_archetype_text: Option<&'a str>,
) -> Result<String, SubagentRunError> {
prompt_context.flow_archetype_text = flow_archetype_text;
load_prompt_source(definition, &prompt_context)