Skip to content

fix(integrations-claude-code): label 'Current time' as UTC in recall context#1568

Merged
nicoloboschi merged 1 commit into
vectorize-io:mainfrom
valda:fix/recall-current-time-utc-label-py
May 25, 2026
Merged

fix(integrations-claude-code): label 'Current time' as UTC in recall context#1568
nicoloboschi merged 1 commit into
vectorize-io:mainfrom
valda:fix/recall-current-time-utc-label-py

Conversation

@valda

@valda valda commented May 11, 2026

Copy link
Copy Markdown
Contributor

Problem

The Hindsight recall hook injects Current time - <ts> into the <hindsight_memories> block on every UserPromptSubmit, but the timestamp is rendered as UTC with no timezone label. Client-side LLMs running in non-UTC timezones routinely misread the value as local time.

Concrete repro #1 (Claude Code, JST / UTC+9):

  • Local wall clock: 2026-05-11 08:55 (morning)
  • Injected line: Current time - 2026-05-10 23:55
  • Result: the model reasons that it is late evening and replies things like "sounds like a good place to wrap up for the day" even though it is morning in the user's actual timezone.

Concrete repro #2 — much worse, observed since the original report:

  • A long-running Claude Code session had an earlier Current time - <ts> line still sitting in its scrolled-back context (UTC value).
  • Later in the same session (local time now ~9 hours ahead in JST), the model re-read that scrolled-back stamp while reasoning about command history, parsed the UTC value as local time, and concluded that a different user had executed the same command roughly 9 hours earlier — i.e. it invented a second actor to explain the apparent time gap.
  • It then opened a security investigation into the "unauthorized duplicate execution." Sounds like a joke but it actually happened.
  • The 9-hour delta is exactly JST→UTC, which is the smoking gun: same root cause as repro Fix dependencies and docker #1, but the failure mode is paranoia / false security incident rather than just a wrong greeting.

Fix

format_current_time() now returns 2026-05-10 23:55 UTC. The UTC suffix matches the convention already used by the opencode integration:

https://github.com/vectorize-io/hindsight/blob/main/hindsight-integrations/opencode/src/hooks.ts#L117

so this is parity rather than novelty.

Scope

  • hindsight-integrations/claude-code/scripts/lib/content.py — the actual change (4 lines)
  • hindsight-integrations/claude-code/tests/test_content.py — regression tests (suffix + format-shape)

The same format_current_time() shape exists in the codex and openclaw integrations and is theoretically affected by the same issue. This PR intentionally leaves them out:

  • The misreading behaviour has only been observed and confirmed against Claude Code by the reporter.
  • hindsight-integrations/codex/scripts/lib/content.py carries pre-existing ruff-format drift in unrelated regions, so editing the same file would either (a) fail verify-generated-files CI or (b) require reformatting ~120 unrelated lines — out of scope for this fix.

Happy to open follow-up PRs for codex / openclaw if you want the parity extended.

Test plan

  • pytest hindsight-integrations/claude-code/tests/test_content.py — 57 passed, including the two new tests.
  • ruff check --config ./ruff.toml hindsight-integrations/claude-code/scripts/lib/content.py — clean.
  • ruff format --config ./ruff.toml --check hindsight-integrations/claude-code/scripts/lib/content.py — already formatted.

Rebase note

Rebased onto 8b10231b Release v0.6.2 to stay current with the v0.6.2 release line.

…context

The recall hook injects "Current time - <ts>" into <hindsight_memories>
without a timezone label, while the value is computed in UTC. Client
LLMs running in non-UTC timezones often misread this as local time —
e.g. a 2026-05-10 23:55 UTC stamp prompts a Claude Code session in JST
(local 2026-05-11 08:55) to remark "sounds like a good place to wrap
up for the day."

The opencode integration already labels its equivalent line with " UTC"
(hindsight-integrations/opencode/src/hooks.ts:117). Aligning claude-code
with that convention removes the foot-gun.
@valda valda force-pushed the fix/recall-current-time-utc-label-py branch from 453d87f to 22527e9 Compare May 23, 2026 02:09

@nicoloboschi nicoloboschi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch!

@nicoloboschi nicoloboschi merged commit 3d6c2ba into vectorize-io:main May 25, 2026
nicoloboschi added a commit that referenced this pull request May 28, 2026
Append ` UTC` to the `Current time -` header injected above recalled
memories. Without the label the LLM read the timestamp as local time and
made wrong recency judgments. This is the same fix that landed for the
Claude Code integration in #1568 — the OpenClaw integration was overlooked.

Closes #1789
nicoloboschi added a commit that referenced this pull request May 28, 2026
#1804)

Append ` UTC` to the `Current time -` header injected above recalled
memories. Without the label the LLM read the timestamp as local time and
made wrong recency judgments. This is the same fix that landed for the
Claude Code integration in #1568 — the OpenClaw integration was overlooked.

Closes #1789
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants