mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 16:24:30 +00:00
fix(memoryFlush): guard transcript-size forced flush against repeated runs (#32358)
The `forceFlushTranscriptBytes` path (introduced in d729ab21) bypasses the
`memoryFlushCompactionCount` guard that prevents repeated flushes within the
same compaction cycle. Once the session transcript exceeds 2 MB, memory flush
fires on every single message — even when token count is well under the
compaction threshold.
Extract `hasAlreadyFlushedForCurrentCompaction()` from the inline guard in
`shouldRunMemoryFlush` and apply it to both the token-based and the
transcript-size trigger paths.
Fixes #32317
Signed-off-by: HCL <chenglunhu@gmail.com>
This commit is contained in:
@@ -31,6 +31,7 @@ import {
|
||||
resolveModelFallbackOptions,
|
||||
} from "./agent-runner-utils.js";
|
||||
import {
|
||||
hasAlreadyFlushedForCurrentCompaction,
|
||||
resolveMemoryFlushContextWindowTokens,
|
||||
resolveMemoryFlushPromptForRun,
|
||||
resolveMemoryFlushSettings,
|
||||
@@ -437,7 +438,9 @@ export async function runMemoryFlushIfNeeded(params: {
|
||||
reserveTokensFloor: memoryFlushSettings.reserveTokensFloor,
|
||||
softThresholdTokens: memoryFlushSettings.softThresholdTokens,
|
||||
})) ||
|
||||
shouldForceFlushByTranscriptSize;
|
||||
(shouldForceFlushByTranscriptSize &&
|
||||
entry != null &&
|
||||
!hasAlreadyFlushedForCurrentCompaction(entry));
|
||||
|
||||
if (!shouldFlushMemory) {
|
||||
return entry ?? params.sessionEntry;
|
||||
|
||||
Reference in New Issue
Block a user