← Back to PRs

#14576: Fix/memory loss bugs

by ENCHIGO open 2026-02-12 09:45 View on GitHub →
docs channel: bluebubbles channel: slack channel: telegram channel: voice-call channel: whatsapp-web app: macos app: web-ui gateway cli scripts commands agents channel: feishu stale size: XL
<!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR hardens session/memory recovery paths: - Adds `saveSessionSnapshotToMemory` to persist a short markdown snapshot of recent transcript content into the agent workspace `memory/` folder before auto-resetting sessions (compaction failure, role ordering conflict, Gemini session corruption). - Improves QMD memory manager robustness by atomically exporting session markdown via temp-file+rename, reducing SQLite busy sensitivity (busy_timeout increase), and skipping doc-path resolution when the index is locked. - Prevents duplicate QMD manager instantiation via a singleflight in `getMemorySearchManager`, and adjusts memory flush logging + behavior when sandbox workspaces are read-only. Key functional integration is in the reply agent reset/corruption handlers, which now attempt to preserve context in workspace memory before deleting transcripts or rotating session IDs. <h3>Confidence Score: 3/5</h3> - This PR is close to safe to merge but has a couple of correctness issues in recovery/snapshot path handling. - Most changes are defensive and well-scoped (singleflight manager creation, atomic exports, additional recovery snapshots). However, the Gemini corruption cleanup currently resolves transcript paths without agent/topic context, which can leave corrupted transcripts in place for non-default agents/threads, and snapshotting prefers `sessionEntry.sessionFile` even when it may not correspond to the provided sessionId—both can undermine the PR’s stated goal of preventing memory loss during resets. - src/auto-reply/reply/agent-runner-execution.ts, src/auto-reply/reply/session-memory-snapshot.ts <!-- greptile_other_comments_section --> <sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub> <!-- /greptile_comment -->

Most Similar PRs