From d0edcec1f92cc663d706edb319519234fa99a416 Mon Sep 17 00:00:00 2001 From: Abdullah Imad Date: Wed, 11 Mar 2026 19:04:23 -0400 Subject: [PATCH] feat(prompt): refresh stale datetime (#3223) The system prompt is built once at daemon startup and cached. The "Current Date & Time" section becomes stale immediately. This patch replaces it with a fresh timestamp every time build_channel_system_prompt is called (i.e. per incoming message). Co-authored-by: Claude Opus 4.6 --- src/channels/mod.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/channels/mod.rs b/src/channels/mod.rs index f93a40a0e..42e26dc07 100644 --- a/src/channels/mod.rs +++ b/src/channels/mod.rs @@ -426,6 +426,25 @@ fn build_channel_system_prompt( ) -> String { let mut prompt = base_prompt.to_string(); + // Refresh the stale datetime in the cached system prompt + { + let now = chrono::Local::now(); + let fresh = format!( + "## Current Date & Time\n\n{} ({})\n", + now.format("%Y-%m-%d %H:%M:%S"), + now.format("%Z"), + ); + if let Some(start) = prompt.find("## Current Date & Time\n\n") { + // Find the end of this section (next "## " heading or end of string) + let rest = &prompt[start + 24..]; // skip past "## Current Date & Time\n\n" + let section_end = rest + .find("\n## ") + .map(|i| start + 24 + i) + .unwrap_or(prompt.len()); + prompt.replace_range(start..section_end, fresh.trim_end()); + } + } + if let Some(instructions) = channel_delivery_instructions(channel_name) { if prompt.is_empty() { prompt = instructions.to_string();