diff --git a/hindsight-integrations/claude-code/scripts/lib/content.py b/hindsight-integrations/claude-code/scripts/lib/content.py index 008c1e702..435bdcea9 100644 --- a/hindsight-integrations/claude-code/scripts/lib/content.py +++ b/hindsight-integrations/claude-code/scripts/lib/content.py @@ -221,10 +221,13 @@ def format_memories(results: list) -> str: def format_current_time() -> str: """Format current UTC time for recall context. + The "UTC" suffix is explicit so client LLMs do not misread the + value as local time when reasoning about wall-clock context. + Port of: formatCurrentTimeForRecall() in index.js """ now = datetime.now(timezone.utc) - return now.strftime("%Y-%m-%d %H:%M") + return now.strftime("%Y-%m-%d %H:%M UTC") # --------------------------------------------------------------------------- diff --git a/hindsight-integrations/claude-code/tests/test_content.py b/hindsight-integrations/claude-code/tests/test_content.py index 51fb3ea69..8aaaeae29 100644 --- a/hindsight-integrations/claude-code/tests/test_content.py +++ b/hindsight-integrations/claude-code/tests/test_content.py @@ -1,11 +1,14 @@ """Tests for lib/content.py — pure content-processing functions.""" +import re + import pytest from lib.content import ( _extract_text_content, _is_channel_message_tool, compose_recall_query, + format_current_time, format_memories, prepare_retention_transcript, slice_last_turns_by_user_boundary, @@ -469,3 +472,18 @@ def test_without_tool_calls_uses_text_format(self): transcript, _ = prepare_retention_transcript(msgs, retain_full_window=True, include_tool_calls=False) assert "[role: user]" in transcript assert "[user:end]" in transcript + + +# --------------------------------------------------------------------------- +# format_current_time +# --------------------------------------------------------------------------- + + +class TestFormatCurrentTime: + def test_includes_utc_suffix(self): + # The "UTC" suffix prevents client LLMs from misreading the + # timestamp as local time. + assert format_current_time().endswith(" UTC") + + def test_format_shape(self): + assert re.fullmatch(r"\d{4}-\d{2}-\d{2} \d{2}:\d{2} UTC", format_current_time())