Skip to content

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

refactor(subagent-host): extract system prompt composition into helper

Steven Enamakel59903e905600
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/prompt.rs b/crates/openhuman-core/src/agent/subagent_host/ops/prompt.rs
index 4711150e0d..739ed9063e 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/prompt.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/prompt.rs
@@ -10,6 +10,26 @@ use tinyagents_harness::artifacts::{
};
use tinytools::ToolSpec;
+/// Compose the leaf role framing with the host's artifact-tool prompt policy.
+pub(crate) fn compose_subagent_system_prompt(
+ base_prompt: String,
+ agent_id: &str,
+ visible_tool_names: &HashSet<String>,
+ task_prompt: &str,
+ spawn_depth: Option<usize>,
+) -> String {
+ let framed = format!(
+ "{}\n\n{}",
+ base_prompt.trim_end(),
+ tinyagents_orchestration::subagent::subagent_framing(
+ tinyagents_orchestration::subagent::SubagentRole::Leaf,
+ spawn_depth,
+ task_prompt,
+ )
+ );
+ append_artifact_offload_contract(framed, agent_id, visible_tool_names)
+}
+
/// Append the filesystem-offload contract (#3883), but only for a sub-agent
/// that actually holds a file-write tool.
///
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
index b10f03c683..50dc046623 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
@@ -32,11 +32,10 @@ use tinyagents_harness::artifacts::{
DEFAULT_OFFLOAD_THRESHOLD_BYTES, HANDOFF_STAGE_RECORDED,
};
use tinyagents_harness::context::{current_run_depth, with_run_depth, RunConfig, RunDepth};
-use tinyagents_orchestration::subagent::{subagent_framing, SubagentRole};
use tinytools::{SandboxMode as TinyagentsSandboxMode, ToolSpec, WorkspaceDescriptor};
use tinytools_std::file_state::with_file_state_agent_id;
-use super::prompt::{append_artifact_offload_contract, dedup_tool_specs_by_name};
+use super::prompt::{compose_subagent_system_prompt, dedup_tool_specs_by_name};
use super::provider::resolve_subagent_source;
/// Runtime spawn-hierarchy gate decision for one delegation hop.
@@ -801,17 +800,13 @@ async fn run_typed_mode(
}
};
- let framing = subagent_framing(
- SubagentRole::Leaf,
- options.run_context.spawn_depth,
+ let system_prompt = compose_subagent_system_prompt(
+ system_prompt,
+ &definition.id,
+ &visible_tool_names,
task_prompt,
+ options.run_context.spawn_depth,
);
- let system_prompt = format!("{}\n\n{framing}", system_prompt.trim_end());
- // #3883: only agents that actually hold a file-write tool are told to
- // offload. `visible_tool_names` is this sub-agent's real, post-filter tool
- // surface, so the contract can never advertise a tool the child cannot call.
- let system_prompt =
- append_artifact_offload_contract(system_prompt, &definition.id, &visible_tool_names);
// ── Build the user message (with optional context prefix) ──────────
// Shared one-line stamp (#3602), in the user's zone like the main agent's.