mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-14 23:10:44 +00:00
refactor(memory): simplify memory flush counter
This commit is contained in:
@@ -231,7 +231,7 @@ Docs: https://docs.openclaw.ai
|
||||
- Docs/Docker: document a local Compose override for Docker Desktop DNS failures in the shared-network `openclaw-cli` sidecar, keeping the default compose setup hardened while unblocking `openclaw plugins install` when users opt in. Fixes #79018. Thanks @Jason-Vaughan.
|
||||
- Installer: when npm installs `openclaw` outside the parent shell PATH, print follow-up commands with the resolved binary path instead of telling users to run `openclaw` from a shell that will report `command not found`. Fixes #72382. Thanks @jbob762.
|
||||
- Plugins/runtime: share MIME and JSON Schema helpers across bundled plugins while preserving canonical media MIME inference, browser URL wildcard semantics, migration home-path resolution, QA request-limit responses, and extensionless text file previews.
|
||||
- Agents/memory flush: persist the pre-increment compaction counter after flush-triggered compaction so consecutive eligible compaction cycles run memoryFlush instead of alternating. Fixes #12590; carries forward #51421 and refs #12760, #26145, and #46513. Thanks @Kaspre, @lailoo, @drvoss, @Br1an67, and @dial481.
|
||||
- Agents/memory flush: persist the pre-increment compaction counter after flush-triggered compaction so consecutive eligible compaction cycles run memoryFlush instead of alternating. Fixes #12590. Refs #12760, #26145, and #46513. Thanks @Kaspre, @lailoo, @drvoss, @Br1an67, and @dial481.
|
||||
- Compute plugin callback authorization dynamically [AI]. (#78866) Thanks @pgondhi987.
|
||||
- fix(active-memory): require admin scope for global toggles [AI]. (#78863) Thanks @pgondhi987.
|
||||
- Honor owner enforcement for native commands [AI]. (#78864) Thanks @pgondhi987.
|
||||
|
||||
@@ -968,7 +968,7 @@ export async function runMemoryFlushIfNeeded(params: {
|
||||
return result;
|
||||
},
|
||||
});
|
||||
const memoryFlushCompactionCount =
|
||||
const flushedCompactionCount =
|
||||
activeSessionEntry?.compactionCount ??
|
||||
(params.sessionKey ? activeSessionStore?.[params.sessionKey]?.compactionCount : 0) ??
|
||||
0;
|
||||
@@ -1001,7 +1001,6 @@ export async function runMemoryFlushIfNeeded(params: {
|
||||
});
|
||||
}
|
||||
}
|
||||
// Persist the pre-increment count so the next compaction cycle remains eligible to flush.
|
||||
}
|
||||
if (params.storePath && params.sessionKey) {
|
||||
try {
|
||||
@@ -1010,7 +1009,7 @@ export async function runMemoryFlushIfNeeded(params: {
|
||||
sessionKey: params.sessionKey,
|
||||
update: async () => ({
|
||||
memoryFlushAt: memoryDeps.now(),
|
||||
memoryFlushCompactionCount,
|
||||
memoryFlushCompactionCount: flushedCompactionCount,
|
||||
}),
|
||||
});
|
||||
if (updatedEntry) {
|
||||
|
||||
@@ -300,23 +300,13 @@ describe("shouldRunMemoryFlush", () => {
|
||||
softThresholdTokens: 2_000,
|
||||
};
|
||||
|
||||
expect(
|
||||
shouldRunMemoryFlush({ entry: { totalTokens: 95_000, compactionCount: 1 }, ...params }),
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
shouldRunMemoryFlush({
|
||||
entry: { totalTokens: 95_000, compactionCount: 2, memoryFlushCompactionCount: 1 },
|
||||
...params,
|
||||
}),
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
shouldRunMemoryFlush({
|
||||
entry: { totalTokens: 95_000, compactionCount: 3, memoryFlushCompactionCount: 2 },
|
||||
...params,
|
||||
}),
|
||||
).toBe(true);
|
||||
for (const entry of [
|
||||
{ totalTokens: 95_000, compactionCount: 1 },
|
||||
{ totalTokens: 95_000, compactionCount: 2, memoryFlushCompactionCount: 1 },
|
||||
{ totalTokens: 95_000, compactionCount: 3, memoryFlushCompactionCount: 2 },
|
||||
]) {
|
||||
expect(shouldRunMemoryFlush({ entry, ...params })).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it("ignores stale cached totals", () => {
|
||||
|
||||
Reference in New Issue
Block a user