Skip to content

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

feat(prompts): classify sections by cache tier

Steven Enamakel447808b1e796
diff --git a/src/openhuman/agent/prompts/sections.rs b/src/openhuman/agent/prompts/sections.rs
index e66a8825b6..13bc2a23e8 100644
--- a/src/openhuman/agent/prompts/sections.rs
+++ b/src/openhuman/agent/prompts/sections.rs
@@ -214,6 +214,11 @@ impl PromptSection for IdentitySection {
"identity"
}
+ fn tier(&self) -> PromptTier {
+ // Carries per-personality recent context.
+ PromptTier::Volatile
+ }
+
fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
let mut prompt = String::from("## Project Context\n\n");
prompt.push_str(
@@ -331,6 +336,11 @@ impl PromptSection for AgentsInstructionsSection {
"agents_md"
}
+ fn tier(&self) -> PromptTier {
+ // PROFILE.md / MEMORY.md — rewritten by the archivist and by onboarding.
+ PromptTier::Volatile
+ }
+
fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
let mut out = String::new();
super::render_helpers::write_agents_md_blocks(
@@ -347,6 +357,11 @@ impl PromptSection for ToolsSection {
"tools"
}
+ fn tier(&self) -> PromptTier {
+ // AGENTS.md layers — per project, stable within a session.
+ PromptTier::Context
+ }
+
fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
// Native function-calling: the provider already sends full JSON
// schemas in the API request — no need to repeat the tool catalogue
@@ -511,6 +526,11 @@ impl PromptSection for RuntimeSection {
"runtime"
}
+ fn tier(&self) -> PromptTier {
+ // Resolved workspace and action dir; per install, not per build.
+ PromptTier::Context
+ }
+
fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
let host =
hostname::get().map_or_else(|_| "unknown".into(), |h| h.to_string_lossy().to_string());
@@ -527,6 +547,11 @@ impl PromptSection for UserReflectionsSection {
"user_reflections"
}
+ fn tier(&self) -> PromptTier {
+ // Host runtime facts; per install, not per build.
+ PromptTier::Context
+ }
+
fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
if ctx.learned.reflections.is_empty() {
return Ok(String::new());
@@ -560,6 +585,11 @@ impl PromptSection for UserMemorySection {
"user_memory"
}
+ fn tier(&self) -> PromptTier {
+ // Learned reflections, refreshed by the learning subsystem.
+ PromptTier::Volatile
+ }
+
fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
if ctx.learned.tree_root_summaries.is_empty() {
return Ok(String::new());
@@ -611,6 +641,11 @@ impl PromptSection for DateTimeSection {
"datetime"
}
+ fn tier(&self) -> PromptTier {
+ // The memory tree summary, which changes whenever memory is written.
+ PromptTier::Volatile
+ }
+
fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
// No concrete timestamp here. The live "now" is injected per turn
// on the user message via `render_helpers::current_datetime_line`
@@ -659,6 +694,16 @@ impl PromptSection for UserIdentitySection {
"user_identity"
}
+ fn tier(&self) -> PromptTier {
+ // The signed-in user, which changes on login and logout.
+ PromptTier::Volatile
+ }
+
+ fn tier(&self) -> PromptTier {
+ // The clock. Nothing after this can ever be cached.
+ PromptTier::Volatile
+ }
+
fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
let identity = match ctx.user_identity.as_ref() {
Some(id) if !id.is_empty() => id,