fix(gateway): invalidate bootstrap cache on session rollover#38535
Conversation
Greptile SummaryThis PR fixes a stale-cache bug (#38494) where bootstrap snapshot files remained in memory after a session rolled over to a new ID on daily/idle/forced resets. The fix adds
Confidence Score: 4/5
Last reviewed commit: 54eb998 |
src/commands/agent/session.ts
Outdated
| if (isNewSession && sessionEntry?.sessionId && sessionKey) { | ||
| clearBootstrapSnapshot(sessionKey); | ||
| } |
There was a problem hiding this comment.
Missing test coverage for this path
The PR adds clearBootstrapSnapshot to resolveSession in this file, but src/commands/agent/session.test.ts only tests resolveSessionKeyForRequest — there are no tests for resolveSession at all. The other two changed files (auto-reply/reply/session.ts and cron/isolated-agent/session.ts) each have corresponding assertions, but this path is left without any test verifying that clearBootstrapSnapshot is called on a stale session rollover or that it is not called when the session is fresh. This leaves a gap in the regression protection that the PR sets out to add.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/commands/agent/session.ts
Line: 148-150
Comment:
**Missing test coverage for this path**
The PR adds `clearBootstrapSnapshot` to `resolveSession` in this file, but `src/commands/agent/session.test.ts` only tests `resolveSessionKeyForRequest` — there are no tests for `resolveSession` at all. The other two changed files (`auto-reply/reply/session.ts` and `cron/isolated-agent/session.ts`) each have corresponding assertions, but this path is left without any test verifying that `clearBootstrapSnapshot` is called on a stale session rollover or that it is **not** called when the session is fresh. This leaves a gap in the regression protection that the PR sets out to add.
How can I resolve this? If you propose a fix, please make it concise.54eb998 to
c7a289a
Compare
c7a289a to
830e974
Compare
|
PR #38535 - fix(gateway): invalidate bootstrap cache on session rollover (#38535) Merged after verification.
|
* main: (45 commits) chore: update dependencies except carbon test(memory): make mcporter EINVAL retry test deterministic refactor(extensions): reuse shared helper primitives refactor(core): extract shared dedup helpers fix(ci): re-enable detect-secrets on main docs: reorder 2026.3.7 changelog highlights chore: bump version to 2026.3.7 fix(android): align run command with app id docs: add changelog entry for Android package rename (openclaw#38712) fix(android): rename app package to ai.openclaw.app fix(gateway): stop stale-socket restarts before first event (openclaw#38643) fix(gateway): skip stale-socket restarts for Telegram polling (openclaw#38405) fix(gateway): invalidate bootstrap cache on session rollover (openclaw#38535) docs: update changelog for reply media delivery (openclaw#38572) fix: contain final reply media normalization failures fix: contain block reply media failures fix: normalize reply media paths Fix owner-only auth and overlapping skill env regressions (openclaw#38548) fix(feishu): disable block streaming to prevent silent reply drops (openclaw#38422) fix: suppress ACP NO_REPLY fragments in console output (openclaw#38436) ...
…w#38535) Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: yfge <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: yfge <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…w#38535) Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: yfge <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…w#38535) Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: yfge <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…w#38535) Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: yfge <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…w#38535) Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: yfge <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…w#38535) Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: yfge <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…w#38535) Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: yfge <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…w#38535) Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: yfge <[email protected]> Co-authored-by: Tak Hoffman <[email protected]> (cherry picked from commit 2e31aea)
…w#38535) Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: yfge <[email protected]> Co-authored-by: Tak Hoffman <[email protected]> (cherry picked from commit 2e31aea)
Background
Session bootstrap files are cached per
sessionKey, but daily/idle rollovers mint a newsessionIdwhile keeping the same key. That left staleAGENTS.md/MEMORY.md/USER.mdsnapshots in memory until gateway restart (see #38494).Changes
sessionIdin the main auto-reply session init path (initSessionState).resolveSession) and isolated cron session resolution (resolveCronSession) so all rollover paths are consistent.Validation
src/auto-reply/reply/session.test.tssrc/cron/isolated-agent/session.test.tspnpmmissing andnpx vitestcannot resolve workspace deps).Impact
Fixes #38494