The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(prompts): expose prompt clock helpers from prompts module
Steven Enamakel1d267e80c3fb
diff --git a/crates/openhuman-core/src/prompts/mod.rs b/crates/openhuman-core/src/prompts/mod.rsindex 750e3b0316..b6ae6ab081 100644--- a/crates/openhuman-core/src/prompts/mod.rs+++ b/crates/openhuman-core/src/prompts/mod.rs@@ -3,6 +3,9 @@pub mod composition;pub mod sections;pub use composition::{SystemPromptBuilder, TieredPrompt, GLOBAL_STYLE_SUFFIX};+pub use section_renderers::{+ current_datetime_line_at, register_prompt_clock, PromptClockRegistration,+};#[path = "section_renderers.rs"]mod section_renderers;diff --git a/crates/openhuman-core/src/prompts/section_renderers.rs b/crates/openhuman-core/src/prompts/section_renderers.rsindex c6542261d2..0b8c2c7e90 100644--- a/crates/openhuman-core/src/prompts/section_renderers.rs+++ b/crates/openhuman-core/src/prompts/section_renderers.rs@@ -263,3 +263,7 @@ fn empty_prompt_context_for_static_sections() -> PromptContext<'static> {flow_archetype_text: None,}}++#[cfg(test)]+#[path = "section_renderers_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/prompts/section_renderers_tests.rs b/crates/openhuman-core/src/prompts/section_renderers_tests.rsnew file mode 100644index 0000000000..65436714d9--- /dev/null+++ b/crates/openhuman-core/src/prompts/section_renderers_tests.rs@@ -0,0 +1,58 @@+use super::*;++fn utc(value: &str) -> DateTime<Utc> {+ DateTime::parse_from_rfc3339(value)+ .expect("valid RFC 3339 timestamp")+ .with_timezone(&Utc)+}++#[test]+fn datetime_line_formats_a_supplied_utc_instant_in_utc_and_iana_zones() {+ let instant = utc("2024-01-01T12:34:56Z");++ assert_eq!(+ current_datetime_line_at(instant, Some("UTC")),+ "Current Date & Time: 2024-01-01 12:34:56 UTC (UTC, UTC+00:00), Monday"+ );+ assert_eq!(+ current_datetime_line_at(instant, Some("Pacific/Chatham")),+ "Current Date & Time: 2024-01-02 02:19:56 Pacific/Chatham (+1345, UTC+13:45), Tuesday"+ );+ assert_eq!(+ current_datetime_line_at(utc("2024-07-01T12:34:56Z"), Some("Pacific/Chatham")),+ "Current Date & Time: 2024-07-02 01:19:56 Pacific/Chatham (+1245, UTC+12:45), Tuesday"+ );+}++#[test]+fn newest_prompt_clock_wins_and_non_lifo_drop_restores_the_remaining_provider() {+ let first = register_prompt_clock(|| utc("2024-01-01T12:00:00Z"));+ let second = register_prompt_clock(|| utc("2024-02-02T13:00:00Z"));+ let third = register_prompt_clock(|| utc("2024-03-03T14:00:00Z"));++ assert_eq!(+ current_datetime_line(Some("UTC")),+ current_datetime_line_at(utc("2024-03-03T14:00:00Z"), Some("UTC"))+ );++ drop(second);+ assert_eq!(+ current_datetime_line(Some("UTC")),+ current_datetime_line_at(utc("2024-03-03T14:00:00Z"), Some("UTC"))+ );+ drop(third);+ assert_eq!(+ current_datetime_line(Some("UTC")),+ current_datetime_line_at(utc("2024-01-01T12:00:00Z"), Some("UTC"))+ );+ drop(first);++ let before = Utc::now();+ let actual = current_datetime_line(Some("UTC"));+ let after = Utc::now();+ assert!(+ actual == current_datetime_line_at(before, Some("UTC"))+ || actual == current_datetime_line_at(after, Some("UTC")),+ "dropping the final registration must restore the live system clock"+ );+}