Skip to content

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

test(prompts): cover legacy dynamic tier marker splitting

Steven Enamakeld426abd89049
diff --git a/crates/openhuman-core/src/agent/prompts/mod_tests.rs b/crates/openhuman-core/src/agent/prompts/mod_tests.rs
index 989b83b418..0d13ab846c 100644
--- a/crates/openhuman-core/src/agent/prompts/mod_tests.rs
+++ b/crates/openhuman-core/src/agent/prompts/mod_tests.rs
@@ -152,3 +152,41 @@ fn swapping_is_a_no_op_without_a_deferred_set() {
assert_eq!(visible.len(), 1);
assert!(visible.contains("shell"));
}
+
+#[test]
+fn legacy_dynamic_tier_markers_preserve_literal_body_slices() {
+ let body = format!(
+ "é stable\n{context}\r\n\n<!--prompt-tier:unknown-->\n{volatile}\n📎 tail",
+ context = PROMPT_TIER_CONTEXT_MARKER,
+ volatile = PROMPT_TIER_VOLATILE_MARKER,
+ );
+
+ assert_eq!(
+ split_prompt_tiers(&body, PromptTier::Volatile),
+ vec![
+ (PromptTier::Volatile, "é stable\n".to_string()),
+ (
+ PromptTier::Context,
+ "\r\n\n<!--prompt-tier:unknown-->\n".to_string(),
+ ),
+ (PromptTier::Volatile, "\n📎 tail".to_string()),
+ ],
+ "markers are trimmed only for recognition; the remaining bytes retain their original line endings and unknown comments"
+ );
+}
+
+#[test]
+fn legacy_dynamic_tier_markers_keep_default_and_repeated_marker_semantics() {
+ assert_eq!(
+ split_prompt_tiers(" only this body ", PromptTier::Stable),
+ vec![(PromptTier::Stable, " only this body ".to_string())]
+ );
+ assert_eq!(
+ split_prompt_tiers(
+ &format!("{context}\n{context}\ncontent", context = PROMPT_TIER_CONTEXT_MARKER),
+ PromptTier::Volatile,
+ ),
+ vec![(PromptTier::Context, "content".to_string())]
+ );
+ assert!(split_prompt_tiers(" \n ", PromptTier::Stable).is_empty());
+}