fix(agents): heartbeat/cron prompts carry stale "Current time" that never refreshes between runs#45071
Conversation
Greptile SummaryThis PR fixes a longstanding stale-timestamp bug in Key observations:
Confidence Score: 5/5
Last reviewed commit: 2f0bf3b |
appendCronStyleCurrentTimeLine previously returned text unchanged when it already contained a "Current time:" line, preserving stale timestamps across heartbeat runs. Replace the early-return guard with a regex substitution so each invocation refreshes the timestamp. Closes openclaw#44993
2f0bf3b to
80cc87c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 80cc87c093
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const existingTimeRe = /^Current time:.*$/m; | ||
| if (existingTimeRe.test(base)) { | ||
| return base.replace(existingTimeRe, timeLine); |
There was a problem hiding this comment.
Restrict timestamp replacement to generated time lines
The new regex replaces any line that starts with Current time: anywhere in the prompt, not just the helper-appended timestamp line. In the heartbeat cron path, buildCronEventPrompt embeds raw event text (src/infra/heartbeat-events-filter.ts), so a user reminder containing a line like Current time: call ops at 5pm will be silently rewritten to the runtime timestamp, changing reminder semantics. This regression is introduced by base.replace(existingTimeRe, timeLine) and can corrupt user-authored cron content when that phrase appears at line start.
Useful? React with 👍 / 👎.
|
Closing this as not reproducible on current Closing as cannot reproduce. On current main, the stale-between-runs path described in the PR does not exist: heartbeat prompts are rebuilt from raw config/system-event text for each run, and the previously injected timestamp is not fed back into appendCronStyleCurrentTimeLine. The proposed regex replacement would also rewrite arbitrary user-authored cron reminder lines that start with "Current time:". What I checked:
Review notes: reviewed against 40be5ad58187. |
Problem
appendCronStyleCurrentTimeLinehas an early-return guard that skips timestamp injection when the text already contains a"Current time:"line:This means heartbeat and cron prompts carry the first timestamp indefinitely — the model sees a frozen clock that never updates between runs.
Reported in #44993 with detailed repro: heartbeat polls and cron events show timestamps from hours or days ago.
Fix
Replace the early-return guard with a regex substitution that refreshes the existing
Current time:line with the currentnowMsvalue on every call. When no line exists, one is appended as before.Before:
base.includes("Current time:") → return base(stale)After:
base.replace(/^Current time:.*$/m, freshTimeLine)(refreshed)This also fixes the same stale-timestamp path in
session-reset-prompt.tsandpost-compaction-context.ts, which reuse the same helper.Tests
Added
src/agents/current-time.test.tswith 6 test cases:Current time:lines after repeated callsresolveCronStyleNowreturns expected formatCloses #44993