openclaw - 💡(How to fix) Fix Optimize prompt caching by moving volatile current-time injection out of cache-sensitive prompt prefixes [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
openclaw/openclaw#71973Fetched 2026-04-27 05:36:42
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Participants

OpenClaw appears to inject a volatile Current time: ... line into heartbeat, cron, and post-compaction prompt content in a way that likely reduces prompt-cache reuse for those turns.

The main concern is not timezone metadata, but exact wall-clock time being inserted into cache-sensitive prompt prefixes.

Root Cause

Prompt caching works best when the front of the prompt remains stable. If a changing Current time: ... line is included early in the prompt body on every heartbeat/cron/event turn, it can invalidate cache reuse for everything that follows.

This likely causes unnecessary cache churn and higher cost / latency for recurring automated runs.

RAW_BUFFERClick to expand / collapse

Summary

OpenClaw appears to inject a volatile Current time: ... line into heartbeat, cron, and post-compaction prompt content in a way that likely reduces prompt-cache reuse for those turns.

The main concern is not timezone metadata, but exact wall-clock time being inserted into cache-sensitive prompt prefixes.

Why this matters

Prompt caching works best when the front of the prompt remains stable. If a changing Current time: ... line is included early in the prompt body on every heartbeat/cron/event turn, it can invalidate cache reuse for everything that follows.

This likely causes unnecessary cache churn and higher cost / latency for recurring automated runs.

What I found

Stable timezone in system prompt

There is a stable section in the system prompt builder:

  • ## Current Date & Time
  • Time zone: ...

That part looks fine and likely remains cacheable.

Volatile current-time helper

There is a helper at:

  • /app/dist/current-time-BkqyYDci.js

It generates a line like:

  • Current time: ... (userTimezone) / ... UTC

Where the volatile line is appended

I found this exact wall-clock line being appended in at least these flows:

  • heartbeat runner
  • cron/system-event execution
  • post-compaction context refresh

Relevant built artifacts observed locally:

  • /app/dist/current-time-BkqyYDci.js
  • /app/dist/heartbeat-runner-dPEnJvN2.js
  • /app/dist/server.impl-B-xK231T.js
  • /app/dist/model-context-tokens-BFDIhVvJ.js

Recommendation

Best fix

Keep stable timezone metadata in the static/system prompt, but move per-turn wall-clock time out of cache-sensitive prompt prefixes.

In practice:

  1. Keep Time zone: ... in stable prompt context
  2. Inject exact Current time: ... as late as possible
  3. Only include exact wall-clock time when the turn truly needs it
  4. Avoid baking fresh time into post-compaction injected blocks unless necessary

Expected benefit

  • Better prompt cache reuse on heartbeat/cron/automation turns
  • Lower token cost
  • Lower latency
  • No loss of timezone awareness

Possible implementation principle

Keep stable user timezone in the static prompt, but move per-turn wall-clock time out of cache-sensitive prompt prefixes and into late-bound runtime/event content only when needed.

Notes

This may not be harming cache reuse for the entire main chat prompt, but it does look like a legitimate optimization target for recurring automation/event turns.

extent analysis

TL;DR

Move the volatile Current time: ... line out of cache-sensitive prompt prefixes to improve prompt cache reuse and reduce unnecessary cache churn.

Guidance

  • Identify and review the code in /app/dist/current-time-BkqyYDci.js to understand how the volatile Current time: ... line is generated and appended to prompts.
  • Modify the heartbeat runner, cron/system-event execution, and post-compaction context refresh flows to inject the exact Current time: ... as late as possible, only when the turn truly needs it.
  • Keep the stable timezone metadata (Time zone: ...) in the static/system prompt, but avoid including the exact wall-clock time in cache-sensitive prompt prefixes.
  • Verify the changes by monitoring prompt cache reuse, token cost, and latency for recurring automation/event turns.

Example

No code snippet is provided as the issue does not contain specific code that can be modified.

Notes

The proposed solution may not completely eliminate cache churn, but it should improve prompt cache reuse for recurring automation/event turns. The exact implementation details may vary depending on the specific requirements of the application.

Recommendation

Apply the workaround by moving the volatile Current time: ... line out of cache-sensitive prompt prefixes, as this is likely to improve prompt cache reuse and reduce unnecessary cache churn, resulting in lower token cost and latency.

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

openclaw - 💡(How to fix) Fix Optimize prompt caching by moving volatile current-time injection out of cache-sensitive prompt prefixes [1 participants]