fix(memory-flush): fire on every compaction cycle instead of skipping alternate cycles (#12590)#12760
Closed
lailoo wants to merge 1 commit into
Closed
fix(memory-flush): fire on every compaction cycle instead of skipping alternate cycles (#12590)#12760lailoo wants to merge 1 commit into
lailoo wants to merge 1 commit into
Conversation
… alternate cycles (openclaw#12590)
bfc1ccb to
f92900f
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #12590
Problem
memoryFlushonly fires on every other auto-compaction cycle. After a flush where compaction also completes,incrementCompactionCountbumpscompactionCountfrom N to N+1, and the code assigns this new value tomemoryFlushCompactionCount— synchronizing both counters. On the next cycle,shouldRunMemoryFlushsees them equal and skips the flush.Fix
Stop overwriting
memoryFlushCompactionCountwith the post-increment value. The flush records the pre-incrementcompactionCount, so the next compaction cycle seescompactionCount > memoryFlushCompactionCountand correctly triggers the flush.Change: 3 lines removed (the
nextCountreassignment),lettoconst.Reproduction and Verification
Before fix (main branch) — Bug reproduced:
After fix — All verified:
Effect on User Experience
Before fix: Users with
memoryFlushenabled see memories saved only on ~50% of compaction cycles. Important context is silently lost.After fix:
memoryFlushfires reliably on every compaction cycle.Testing
memory-flush.test.ts)agent-runner.memory-flush.*.test.ts)Greptile Overview
Greptile Summary
This change fixes a regression where
memoryFlushwas only firing every other auto-compaction cycle. Insrc/auto-reply/reply/agent-runner-memory.ts, the flush now recordsmemoryFlushCompactionCountusing the pre-incrementcompactionCountand no longer overwrites it with the post-increment value returned byincrementCompactionCount, which previously synchronized the counters and caused the next cycle to be skipped.Tests were updated to reflect the intended behavior by asserting
memoryFlushCompactionCountremains at the pre-increment value even whencompactionCountis incremented after a flush, and a new unit test was added to confirmshouldRunMemoryFlushtriggers across successive compaction counts.Confidence Score: 5/5
incrementCompactionCountpersists only the compaction increment whilememoryFlushCompactionCountis persisted separately. Updated tests lock in the intended pre-increment recording behavior and cover the regression scenario at the unit and integration level.