fix: patch cache bust in the system prompt via timestamp [LET-4155] (#4375)

fix: patch cache bust in the system prompt via timestamp
This commit is contained in:
Charles Packer
2025-09-02 18:07:13 -07:00
committed by GitHub
parent e40c0512c2
commit 46672de2d6
2 changed files with 5 additions and 3 deletions

View File

@@ -20,11 +20,13 @@ def datetime_to_timestamp(dt):
def get_local_time_fast(timezone):
# Get current UTC time and convert to the specified timezone
# Only return the date to avoid cache busting on every request
if not timezone:
return datetime.now().strftime("%Y-%m-%d %I:%M:%S %p %Z%z")
return datetime.now().strftime("%B %d, %Y")
current_time_utc = datetime.now(pytz.utc)
local_time = current_time_utc.astimezone(pytz.timezone(timezone))
formatted_time = local_time.strftime("%Y-%m-%d %I:%M:%S %p %Z%z")
# Return only the date in a human-readable format (e.g., "June 1, 2021")
formatted_time = local_time.strftime("%B %d, %Y")
return formatted_time

View File

@@ -52,7 +52,7 @@ class PromptGenerator:
# Create a metadata block of info so the agent knows about the metadata of out-of-context memories
metadata_lines = [
"<memory_metadata>",
f"- The current time is: {get_local_time_fast(timezone)}",
f"- The current system date is: {get_local_time_fast(timezone)}",
f"- Memory blocks were last modified: {timestamp_str}",
f"- {previous_message_count} previous messages between you and the user are stored in recall memory (use tools to access them)",
]