Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion hindsight-integrations/claude-code/scripts/lib/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


# ---------------------------------------------------------------------------
Expand Down
18 changes: 18 additions & 0 deletions hindsight-integrations/claude-code/tests/test_content.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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())