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(agent): stamp each turn's date line in the user's time zone
M3gA-Mindd27cd27e967b
diff --git a/crates/openhuman-core/src/agent/prompts/mod_tests_builder_sections_tests.rs b/crates/openhuman-core/src/agent/prompts/mod_tests_builder_sections_tests.rsindex 7731b1b5b7..2b2c24e585 100644--- a/crates/openhuman-core/src/agent/prompts/mod_tests_builder_sections_tests.rs+++ b/crates/openhuman-core/src/agent/prompts/mod_tests_builder_sections_tests.rs@@ -238,7 +238,7 @@ fn current_datetime_line_is_fresh_local_stamp() {// The per-turn stamp carries a parseable local date, IANA zone (or the// `UTC` fallback), a UTC offset, and the weekday — everything the model// needs to localize a greeting without a tool call (#3602).- let line = super::super::current_datetime_line();+ let line = super::super::current_datetime_line(None);let rest = line.strip_prefix("Current Date & Time: ").unwrap_or_else(|| panic!("stamp must start with canonical prefix: {line}"));@@ -255,6 +255,23 @@ fn current_datetime_line_is_fresh_local_stamp() {);}+/// The stamp reads in the user's zone, not the machine's; a name chrono-tz+/// does not know falls back to the device stamp rather than echoing it.+#[test]+fn current_datetime_line_is_stamped_in_the_users_zone() {+ let line = super::super::current_datetime_line(Some("Pacific/Chatham"));+ let now = chrono::Utc::now().with_timezone(&chrono_tz::Pacific::Chatham);+ assert!(line.contains(" Pacific/Chatham ("), "{line}");+ assert!(+ line.contains(&format!("UTC{}", now.format("%:z"))),+ "{line}"+ );+ assert!(line.contains(&now.format("%Y-%m-%d").to_string()), "{line}");++ let line = super::super::current_datetime_line(Some("Not/AZone"));+ assert!(!line.contains("Not/AZone"), "{line}");+}+#[test]fn datetime_section_appends_resolve_time_rule_only_when_tool_present() {// With `resolve_time` in the agent's tool set, the time-discipline rulediff --git a/crates/openhuman-core/src/agent/prompts/render_helpers/section_renderers.rs b/crates/openhuman-core/src/agent/prompts/render_helpers/section_renderers.rsindex 8bb7d5eba0..66c839c90d 100644--- a/crates/openhuman-core/src/agent/prompts/render_helpers/section_renderers.rs+++ b/crates/openhuman-core/src/agent/prompts/render_helpers/section_renderers.rs@@ -66,7 +66,10 @@ pub fn render_datetime(ctx: &PromptContext<'_>) -> Result<String> {/// the prefix both busts the KV cache and goes stale across a long-lived/// session. The static grounding *rule* that tells the model to read this/// line lives in [`DateTimeSection`] / [`render_datetime`].-pub fn current_datetime_line() -> String {+///+/// `zone` is the user's IANA zone ([`crate::config::Config::time_zone`]);+/// `None`, or a name chrono-tz does not know, stamps the device's.+pub fn current_datetime_line(zone: Option<&str>) -> String {// `library-cpu.sh` sets `OPENHUMAN_PROFILE_FORCE_UTC=1` to skip// `iana_time_zone`/CoreFoundation timezone resolution, which is itself a// measurable cost in a cold CPU profile. Gated on `rss-bench`, so it does@@ -81,6 +84,18 @@ pub fn current_datetime_line() -> String {);}+ if let Some(tz) = zone.and_then(|zone| zone.parse::<chrono_tz::Tz>().ok()) {+ let now = chrono::Utc::now().with_timezone(&tz);+ return format!(+ "Current Date & Time: {} {} ({}, UTC{}), {}",+ now.format("%Y-%m-%d %H:%M:%S"),+ tz.name(),+ now.format("%Z"),+ now.format("%:z"),+ now.format("%A"),+ );+ }+// When the host resolves an IANA zone, stamp local time + that zone. When// it can't (CI, stripped containers), fall back to true UTC — formatting// `Utc::now()` so the time, offset, and zone label all agree rather than@@ -112,8 +127,8 @@ pub fn current_datetime_line() -> String {/// reply-language instruction for the user's interface locale, when there is/// one. Per message, never in the cached prompt prefix, so a locale change/// applies from the next turn and the prefix stays byte-stable.-pub fn turn_preamble(reply_language_directive: Option<&str>) -> String {- let now = current_datetime_line();+pub fn turn_preamble(reply_language_directive: Option<&str>, zone: Option<&str>) -> String {+ let now = current_datetime_line(zone);match reply_language_directive {Some(directive) => format!("{now}\n{directive}"),None => now,diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_build.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_build.rsindex 12fd5e8ac7..f03f331fb6 100644--- a/crates/openhuman-core/src/agent/session_host/builder/builder_build.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_build.rs@@ -407,9 +407,13 @@ impl SessionHostBuilder {Ok(OpenHumanSessionHost {runtime_session: None,- runtime_state: Arc::new(std::sync::Mutex::new(- super::super::runtime_session::OpenHumanSessionState::default(),- )),+ runtime_state: Arc::new(std::sync::Mutex::new({+ let mut state = super::super::runtime_session::OpenHumanSessionState::default();+ state.time_zone = runtime_config+ .as_deref()+ .map(crate::config::Config::time_zone);+ state+ })),turn_model_source,tools,synthesized_tools,diff --git a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rsindex 126b11fb9e..7a2a7cac75 100644--- a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs@@ -568,6 +568,15 @@ impl OpenHumanSessionHost {.reply_language_directive = directive;}+ /// The user's IANA time zone, which the date line on each later user+ /// message is stamped in (`None`: the device's).+ pub fn set_time_zone(&mut self, zone: Option<String>) {+ self.runtime_state+ .lock()+ .unwrap_or_else(|poisoned| poisoned.into_inner())+ .time_zone = zone;+ }+/// The reply-language instruction the next user message will carry.pub fn reply_language_directive(&self) -> Option<String> {self.runtime_statediff --git a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rsindex e283c5cc0e..2a0f63199f 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs@@ -686,6 +686,7 @@ async fn reply_language_directive_rides_each_user_message_until_cleared_body() {};host.set_reply_language_directive(Some(DIRECTIVE.to_string()));+ host.set_time_zone(Some("Pacific/Chatham".to_string()));assert_eq!(host.turn("¿qué tal?").await.unwrap(), "hola");host.set_reply_language_directive(None);assert_eq!(host.turn("and now?").await.unwrap(), "hello");@@ -701,6 +702,10 @@ async fn reply_language_directive_rides_each_user_message_until_cleared_body() {first.contains(DIRECTIVE),"the directive must reach the model: {first}");+ assert!(+ first.contains(" Pacific/Chatham ("),+ "the clock reads in the user's zone: {first}"+ );assert!(first.find(DIRECTIVE) < first.find("¿qué tal?"),"the directive leads the user's own words: {first}"diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rsindex ecccccffdf..8733f6e367 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs@@ -55,6 +55,7 @@ pub(super) struct OpenHumanSessionState {pub(crate) pending_turn_overrides: super::types::TurnOverrides,pub(super) active_turn_overrides: super::types::TurnOverrides,pub(super) reply_language_directive: Option<String>,+ pub(super) time_zone: Option<String>,prelude: Option<OpenHumanTurnPrelude>,}@@ -634,10 +635,7 @@ impl OpenHumanTurnPrelude {self.tool_dispatcher.tool_call_format(),).harness_dispatcher();- format!(- "{}\n\n{enriched}",- crate::agent::prompts::turn_preamble(turn.reply_language_directive.as_deref())- )+ format!("{}\n\n{enriched}", turn.preamble())}fn parent_context(&self) -> crate::agent::harness::ParentExecutionContext {diff --git a/crates/openhuman-core/src/agent/session_host/types.rs b/crates/openhuman-core/src/agent/session_host/types.rsindex 2adb467916..0d2df0f3fe 100644--- a/crates/openhuman-core/src/agent/session_host/types.rs+++ b/crates/openhuman-core/src/agent/session_host/types.rs@@ -62,6 +62,18 @@ pub struct TurnOverrides {pub(crate) struct TurnInputs {pub(crate) overrides: TurnOverrides,pub(crate) reply_language_directive: Option<String>,+ pub(crate) time_zone: Option<String>,+}++impl TurnInputs {+ /// What leads this turn's user message: the date line in the user's time+ /// zone, then the reply-language instruction.+ pub(crate) fn preamble(&self) -> String {+ crate::agent::prompts::turn_preamble(+ self.reply_language_directive.as_deref(),+ self.time_zone.as_deref(),+ )+ }}impl super::runtime_session::OpenHumanSessionState {@@ -71,6 +83,7 @@ impl super::runtime_session::OpenHumanSessionState {TurnInputs {overrides: std::mem::take(&mut self.active_turn_overrides),reply_language_directive: self.reply_language_directive.clone(),+ time_zone: self.time_zone.clone(),}}}diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rsindex 90fff55486..60702d2c6e 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs@@ -858,10 +858,10 @@ async fn run_typed_mode(append_artifact_offload_contract(system_prompt, &definition.id, &visible_tool_names);// ── Build the user message (with optional context prefix) ──────────- // Shared one-line stamp (#3602) so sub-agents report time in the same- // format as the main agent. Lives on the user message because sub-agent- // system prompts are byte-stable for prefix caching.- let now_str = crate::agent::prompts::current_datetime_line();+ // Shared one-line stamp (#3602), in the user's zone like the main agent's.+ // On the user message: sub-agent system prompts are byte-stable for caching.+ let zone = config.as_ref().ok().map(|c| c.time_zone());+ let now_str = crate::agent::prompts::current_datetime_line(zone.as_deref());let mut context_parts: Vec<&str> = Vec::new();if !definition.omit_memory_context {diff --git a/crates/openhuman-core/src/web_chat/session.rs b/crates/openhuman-core/src/web_chat/session.rsindex 03f1f3c653..d6bbc41bf1 100644--- a/crates/openhuman-core/src/web_chat/session.rs+++ b/crates/openhuman-core/src/web_chat/session.rs@@ -482,6 +482,9 @@ pub(crate) async fn checkout_session_agent();}agent.set_reply_language_directive(directive);+ // Re-read per message too, so a zone changed in Settings applies to the+ // next message of an open conversation.+ agent.set_time_zone(Some(config.time_zone()));// Cold-boot resume needs no seeding here. `set_thread_id` binds the// session's durable identity and the turn resumes by it, reading the onediff --git a/scripts/ci/check-openhuman-rust-layout.mjs b/scripts/ci/check-openhuman-rust-layout.mjsindex 77f9e69513..c28497b3e0 100644--- a/scripts/ci/check-openhuman-rust-layout.mjs+++ b/scripts/ci/check-openhuman-rust-layout.mjs@@ -38,7 +38,7 @@ const LEGACY_LIMIT_ENTRIES = [// under the general 750 limit, so it needs no exception at all.// The session-todo integration added transcript metadata construction to// this already-exempt composition seam. Keep its allowance exact.- ["crates/openhuman-core/src/agent/session_host/runtime_session.rs", 1476],+ ["crates/openhuman-core/src/agent/session_host/runtime_session.rs", 1474],// Session-host factory still assembles the product's deliberately coupled// provider, security, memory, tool and prompt policy. Generic session// state moved to tinyagents-runtime; this remaining composition is split in