Skip to content

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

feat(session): append tool policy boundary to volatile prompt tier

Steven Enamakel4f95a55b15fe
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/prelude.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/prelude.rs
index ec347f68cf..7b88893ea8 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session/prelude.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/prelude.rs
@@ -184,7 +184,28 @@ impl OpenHumanTurnPrelude {
agents_md_global: agents_md.global,
agents_md_local: agents_md.local,
};
- self.prompt_builder.build_tiered(&context)
+ let mut tiered = self.prompt_builder.build_tiered(&context)?;
+ // Appended, not prepended (#5704): every line of the boundary is
+ // session-scoped (agent id, channel, entry point, risk level), so
+ // putting it first would move the prompt's first diverging byte to
+ // offset 0 and cost the backend's prefix cache everything behind it.
+ // It rides the volatile tier, which is the tail of the system prompt.
+ if let Some(boundary) =
+ tinytools::render_tool_policy_boundary(&surface.tool_policy_session, 2048)
+ {
+ let boundary = boundary.trim_end().to_string();
+ if !tiered.text.is_empty() && !tiered.text.ends_with('\n') {
+ tiered.text.push('\n');
+ }
+ tiered.text.push('\n');
+ tiered.text.push_str(&boundary);
+ tiered.text.push('\n');
+ tiered.parts.push((
+ crate::agent::prompts::PromptTier::Volatile,
+ format!("\n\n{boundary}"),
+ ));
+ }
+ Ok(tiered)
}
pub(super) fn drain_host_events(&self) -> bool {