Skip to content

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

refactor(prompts): disambiguate dynamic prompt section trait and widen build visibility

Steven Enamakel3433efc7e94c
diff --git a/crates/openhuman-core/src/prompts/composition.rs b/crates/openhuman-core/src/prompts/composition.rs
index 964353d470..9e2cf2df82 100644
--- a/crates/openhuman-core/src/prompts/composition.rs
+++ b/crates/openhuman-core/src/prompts/composition.rs
@@ -6,7 +6,9 @@ use crate::agent::prompts::types::{
use crate::prompts::sections::*;
use anyhow::{Result, anyhow};
use std::path::Path;
-use tinyagents_harness::prompt::{DynamicPromptSection, PromptComposer};
+use tinyagents_harness::prompt::{
+ DynamicPromptSection as OwnerDynamicPromptSection, PromptComposer,
+};
/// Bundled seed for the workspace's editable writing-style rules.
pub const GLOBAL_STYLE_SUFFIX: &str = include_str!("../agent/prompts/STYLE.md");
@@ -34,7 +36,7 @@ enum ProductSection {
Runtime,
}
-impl<'a> DynamicPromptSection<PromptContext<'a>> for ProductSection {
+impl<'a> OwnerDynamicPromptSection<PromptContext<'a>> for ProductSection {
fn name(&self) -> &str {
match self {
Self::Archetype(_) => "archetype_prompt",
@@ -52,7 +54,9 @@ impl<'a> DynamicPromptSection<PromptContext<'a>> for ProductSection {
fn render(&self, context: &PromptContext<'a>) -> tinyagents_harness::Result<Vec<TieredPromptPart>> {
match self {
Self::Archetype(body) => ArchetypePromptSection::new(body.clone()).render(context),
- Self::Dynamic(builder) => DynamicPromptSection::new(*builder).render(context),
+ Self::Dynamic(builder) => {
+ crate::prompts::sections::DynamicPromptSection::new(*builder).render(context)
+ }
Self::Identity => IdentitySection.render(context),
Self::AgentsInstructions => AgentsInstructionsSection.render(context),
Self::Tools => ToolsSection.render(context),
@@ -69,7 +73,7 @@ struct OpenHumanPromptContent {
verbatim: bool,
}
-impl<'a> DynamicPromptSection<PromptContext<'a>> for OpenHumanPromptContent {
+impl<'a> OwnerDynamicPromptSection<PromptContext<'a>> for OpenHumanPromptContent {
fn name(&self) -> &str {
"openhuman_prompt_content"
}
diff --git a/crates/openhuman-core/src/prompts/sections.rs b/crates/openhuman-core/src/prompts/sections.rs
index 96bfd206a5..3cb8f82c62 100644
--- a/crates/openhuman-core/src/prompts/sections.rs
+++ b/crates/openhuman-core/src/prompts/sections.rs
@@ -35,7 +35,7 @@ impl ArchetypePromptSection {
"archetype_prompt"
}
- fn build(&self, _ctx: &PromptContext<'_>) -> Result<String> {
+ pub(crate) fn build(&self, _ctx: &PromptContext<'_>) -> Result<String> {
if self.body.trim().is_empty() {
return Ok(String::new());
}
@@ -135,7 +135,7 @@ impl PersonalityRosterSection {
"personality_roster"
}
- fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
+ pub(crate) fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
if ctx.personality_roster.is_empty() {
return Ok(String::new());
}
@@ -170,7 +170,7 @@ impl IdentitySection {
"identity"
}
- fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
+ pub(crate) fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
let mut prompt = String::new();
// ROLE.md is the user-facing agent's own role brief (#5701) — the
// `# Master Agent` / `## Core Responsibilities` preamble that used to
@@ -206,7 +206,7 @@ impl AgentsInstructionsSection {
"agents_md"
}
- fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
+ pub(crate) fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
let mut out = String::new();
crate::prompts::write_agents_md_blocks(
&mut out,
@@ -222,7 +222,7 @@ impl ToolsSection {
"tools"
}
- fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
+ pub(crate) fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
let browser_deferred = ctx.tools.iter().any(|tool| {
matches!(tool.name.as_ref(), "browser" | "browser_open")
&& !ctx.visible_tool_names.contains(tool.name.as_ref())
@@ -300,7 +300,7 @@ impl SafetySection {
"safety"
}
- fn build(&self, _ctx: &PromptContext<'_>) -> Result<String> {
+ pub(crate) fn build(&self, _ctx: &PromptContext<'_>) -> Result<String> {
Ok("## Safety\n\n- Do not exfiltrate private data.\n- Do not run destructive commands without asking.\n- Do not bypass oversight or approval mechanisms.\n- Prefer `trash` over `rm`.\n- When in doubt, ask before acting externally.".into())
}
}
@@ -350,7 +350,7 @@ impl GroundingSection {
"grounding"
}
- fn build(&self, _ctx: &PromptContext<'_>) -> Result<String> {
+ pub(crate) fn build(&self, _ctx: &PromptContext<'_>) -> Result<String> {
Ok(GROUNDING_BODY.into())
}
}
@@ -360,7 +360,7 @@ impl WorkspaceSection {
"workspace"
}
- fn build(&self, _ctx: &PromptContext<'_>) -> Result<String> {
+ pub(crate) fn build(&self, _ctx: &PromptContext<'_>) -> Result<String> {
// Intentionally does NOT print a hardcoded path: `shell` and the file
// tools resolve relative paths against the agent's *action directory*,
// which is not `workspace_dir`. Printing `workspace_dir` here used to
@@ -401,7 +401,7 @@ impl RuntimeSection {
"runtime"
}
- fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
+ pub(crate) fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
// A SaaS process serves many users; the machine it runs on is not
// theirs to know.
let host = if crate::core::runtime::is_saas() {
@@ -422,7 +422,7 @@ impl DateTimeSection {
"datetime"
}
- fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
+ pub(crate) fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
// No concrete timestamp here. The live "now" is injected per turn
// on the user message via `current_datetime_line`
// (the main session loop and the sub-agent runner both do this), so
@@ -459,7 +459,7 @@ impl UserIdentitySection {
"user_identity"
}
- fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
+ pub(crate) fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
let identity = match ctx.user_identity.as_ref() {
Some(id) if !id.is_empty() => id,
_ => return Ok(String::new()),