claude-code - 💡(How to fix) Fix Expose message timestamps to the model in Claude Code sessions [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#47160Fetched 2026-04-13 05:39:51
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
labeled ×2

Fix Action

Fix / Workaround

Workarounds today

RAW_BUFFERClick to expand / collapse

Problem

Claude Code sessions don't expose message timestamps to the model. Claude sees the content of previous messages but has no idea when they were sent. This creates several real bugs in long-running sessions:

Concrete scenarios where this breaks

  1. "Good night" → 10 seconds → "Good morning" Tested this live: said "good night" at end of a session, typed "good morning" 10 seconds later, and Claude enthusiastically summarized "where we left off last night" and offered a new-day action list. It had no way to know less than a minute had passed.

  2. Background task status checks When a run_in_background task is kicked off, Claude can't tell whether it's been running for 2 seconds or 20 minutes without calling tail on the log. Timestamps would make "should I check again now?" trivial.

  3. Re-grounding after idle Claude has no way to distinguish "user paused for 30 seconds to read" from "user left 3 hours ago and is now back." After 3 hours, a full re-ground (read handoff, check git status) is appropriate. After 30 seconds, it's noise.

  4. Avoiding repeated status updates If Claude just posted a 10-line status update 20 seconds ago and the user says "ok", there's no reason to re-post the status. But without timestamps, Claude can't tell a rapid back-and-forth from a stale resume.

  5. Session continuity vs new day Currently I rely on greeting keywords ("good morning") and context to guess whether it's a new session. This is trivially fooled, as demonstrated in (1).

Proposed solution

Inject a timestamp into each user message as a hidden system annotation, e.g.:

``` <message timestamp="2026-04-13T03:47:12Z"> user content here </message> ```

Or as a separate metadata field in the message envelope — the exact format is less important than the fact that the model can read it. Tool results already have metadata (the environment-info block at session start), so there's precedent.

Why this matters more than it sounds

For one-shot "write me a function" prompts, timestamps are irrelevant. But Claude Code sessions routinely run for hours with mixed idle/active periods — debugging, waiting for builds, running background tasks, pausing to test in the browser. The model currently has to guess conversation timing from content alone, which is unreliable and occasionally embarrassing.

Workarounds today

None that the user doesn't have to remember. I can ask the user what time it is, but that's asking them to compensate for a gap in the tooling.

extent analysis

TL;DR

Injecting a timestamp into each user message as a hidden system annotation is the most likely fix to address the issue of Claude Code sessions not exposing message timestamps to the model.

Guidance

  • Consider adding a timestamp field to the message envelope, similar to the existing environment-info block, to provide the model with conversation timing information.
  • Evaluate the proposed solution of injecting a timestamp into each user message as a hidden system annotation, using a format such as <message timestamp="2026-04-13T03:47:12Z">user content here</message>.
  • Assess the impact of adding timestamps on the model's ability to distinguish between different scenarios, such as "Good night" → "Good morning", background task status checks, and re-grounding after idle.
  • Investigate how timestamps can help avoid repeated status updates and improve session continuity vs new day detection.

Example

<message timestamp="2026-04-13T03:47:12Z">
  user content here
</message>

This example illustrates the proposed solution of adding a timestamp to each user message.

Notes

The exact format of the timestamp is less important than the fact that the model can read it. The existing tool results already have metadata, so there is precedent for adding additional information to the message envelope.

Recommendation

Apply the workaround of injecting a timestamp into each user message as a hidden system annotation, as it addresses the core issue of the model not having access to conversation timing information.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING