Skip to content

fix(sessions): updateLastRoute must not bump updatedAt (#49515)#49588

Merged
BradGroux merged 1 commit intoopenclaw:mainfrom
eliot-onbox:fix/session-idle-reset-49515
Apr 23, 2026
Merged

fix(sessions): updateLastRoute must not bump updatedAt (#49515)#49588
BradGroux merged 1 commit intoopenclaw:mainfrom
eliot-onbox:fix/session-idle-reset-49515

Conversation

@eliot-onbox
Copy link
Copy Markdown
Contributor

Fixes #49515

Problem

updateLastRoute() used mergeSessionEntry which bumps updatedAt to Date.now() on every inbound message. This prevented session idle and daily reset from ever firing, since evaluateSessionFreshness() always saw a fresh updatedAt.

The fix from #32379 patched recordSessionMetaFromInbound to use mergeSessionEntryPreserveActivity, but missed updateLastRoute() in the same inbound pipeline.

Fix

  • Remove explicit updatedAt from updateLastRoute basePatch (routing should not write activity timestamps)
  • Switch from mergeSessionEntry to mergeSessionEntryPreserveActivity (belt-and-suspenders: resolveMergedUpdatedAt has a Date.now() fallback that would still bump activity without the preserve-activity policy)
  • Add regression test verifying updatedAt is preserved across route updates
  • Update existing test assertion to match corrected behavior

Context

The comment at line 860 of store.ts already documents the principle:

Inbound metadata updates must not refresh activity timestamps; idle reset evaluation relies on updatedAt from actual session turns.

This PR applies the same principle to updateLastRoute(), completing the fix started in #32379.

Testing

  • New test: updateLastRoute does not bump updatedAt on existing sessions (#49515)
  • Updated existing test: updateLastRoute persists channel and target — assertion changed from toBeGreaterThanOrEqual(123) to toBe(123)

updateLastRoute() used mergeSessionEntry which bumps updatedAt to
Date.now() on every inbound message. This prevented session idle
and daily reset from ever firing, since evaluateSessionFreshness()
always saw a fresh updatedAt.

The fix from openclaw#32379 patched recordSessionMetaFromInbound to use
mergeSessionEntryPreserveActivity, but missed updateLastRoute() in
the same inbound pipeline.

Changes:
- Remove explicit updatedAt from updateLastRoute basePatch
- Switch from mergeSessionEntry to mergeSessionEntryPreserveActivity
- Add regression test verifying updatedAt is preserved
- Update existing test assertion to match corrected behavior

Fixes openclaw#49515
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 18, 2026

Greptile Summary

This PR completes a bug fix started in #32379, ensuring that updateLastRoute() no longer bumps the session's updatedAt timestamp. Previously, two issues caused this: (1) basePatch explicitly set updatedAt to Math.max(existing?.updatedAt ?? 0, now), and (2) mergeSessionEntry was used, which internally calls Math.max(..., Date.now()) as a fallback. Together these caused the session to always appear fresh, preventing idle and daily reset timers from ever firing.

Key changes:

  • updatedAt is removed from basePatch in updateLastRoute, so routing operations no longer carry an activity timestamp.
  • mergeSessionEntry is replaced with mergeSessionEntryPreserveActivity, which uses the preserve-activity policy in resolveMergedUpdatedAt — returning existing.updatedAt unchanged when a session already exists.
  • The existing test assertion is corrected from toBeGreaterThanOrEqual(123) to toBe(123), reflecting the new (correct) behavior.
  • A new regression test is added that explicitly verifies updatedAt is frozen at frozenUpdatedAt = 1000 after a route update.

Confidence Score: 5/5

  • This PR is safe to merge — the change is minimal, targeted, and well-tested.
  • The fix is a one-line removal (stale updatedAt from basePatch) and a one-function swap (mergeSessionEntrymergeSessionEntryPreserveActivity). Both sides of the dual protection align with the already-documented principle at line 860 of store.ts. The mergeSessionEntryPreserveActivity implementation has been verified: with preserve-activity policy and an existing session, resolveMergedUpdatedAt returns existing.updatedAt directly. For new sessions (no existing), it falls back to Date.now(), which is correct. The regression test directly validates the bug scenario, and the updated test assertion now matches the intended invariant.
  • No files require special attention.

Last reviewed commit: "fix(sessions): updat..."

@BradGroux BradGroux merged commit 94f703a into openclaw:main Apr 23, 2026
5 checks passed
steipete pushed a commit that referenced this pull request Apr 23, 2026
updateLastRoute() used mergeSessionEntry which bumps updatedAt to
Date.now() on every inbound message. This prevented session idle
and daily reset from ever firing, since evaluateSessionFreshness()
always saw a fresh updatedAt.

The fix from #32379 patched recordSessionMetaFromInbound to use
mergeSessionEntryPreserveActivity, but missed updateLastRoute() in
the same inbound pipeline.

Changes:
- Remove explicit updatedAt from updateLastRoute basePatch
- Switch from mergeSessionEntry to mergeSessionEntryPreserveActivity
- Add regression test verifying updatedAt is preserved
- Update existing test assertion to match corrected behavior

Fixes #49515

(cherry picked from commit 94f703a)
medikoo pushed a commit to medikoo/openclaw that referenced this pull request Apr 24, 2026
… (openclaw#49588)

updateLastRoute() used mergeSessionEntry which bumps updatedAt to
Date.now() on every inbound message. This prevented session idle
and daily reset from ever firing, since evaluateSessionFreshness()
always saw a fresh updatedAt.

The fix from openclaw#32379 patched recordSessionMetaFromInbound to use
mergeSessionEntryPreserveActivity, but missed updateLastRoute() in
the same inbound pipeline.

Changes:
- Remove explicit updatedAt from updateLastRoute basePatch
- Switch from mergeSessionEntry to mergeSessionEntryPreserveActivity
- Add regression test verifying updatedAt is preserved
- Update existing test assertion to match corrected behavior

Fixes openclaw#49515

(cherry picked from commit 94f703a)
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
… (openclaw#49588)

updateLastRoute() used mergeSessionEntry which bumps updatedAt to
Date.now() on every inbound message. This prevented session idle
and daily reset from ever firing, since evaluateSessionFreshness()
always saw a fresh updatedAt.

The fix from openclaw#32379 patched recordSessionMetaFromInbound to use
mergeSessionEntryPreserveActivity, but missed updateLastRoute() in
the same inbound pipeline.

Changes:
- Remove explicit updatedAt from updateLastRoute basePatch
- Switch from mergeSessionEntry to mergeSessionEntryPreserveActivity
- Add regression test verifying updatedAt is preserved
- Update existing test assertion to match corrected behavior

Fixes openclaw#49515
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
… (openclaw#49588)

updateLastRoute() used mergeSessionEntry which bumps updatedAt to
Date.now() on every inbound message. This prevented session idle
and daily reset from ever firing, since evaluateSessionFreshness()
always saw a fresh updatedAt.

The fix from openclaw#32379 patched recordSessionMetaFromInbound to use
mergeSessionEntryPreserveActivity, but missed updateLastRoute() in
the same inbound pipeline.

Changes:
- Remove explicit updatedAt from updateLastRoute basePatch
- Switch from mergeSessionEntry to mergeSessionEntryPreserveActivity
- Add regression test verifying updatedAt is preserved
- Update existing test assertion to match corrected behavior

Fixes openclaw#49515
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session idle/daily reset never fires: updateLastRoute() bumps updatedAt before freshness check

2 participants