Merge 1857ff82a1cb9098cfd731909a058800d5d44404 into 598f1826d8b2bc969aace2c6459824737667218c
This commit is contained in:
commit
7f136f211a
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
@ -359,7 +359,7 @@ importers:
|
||||
version: 10.6.2
|
||||
openclaw:
|
||||
specifier: '>=2026.3.11'
|
||||
version: 2026.3.13(@napi-rs/canvas@0.1.95)(@types/express@5.0.6)(audio-decode@2.2.3)(jimp@1.6.0)(node-llama-cpp@3.16.2(typescript@5.9.3))
|
||||
version: 2026.3.13(@discordjs/opus@0.10.0)(@napi-rs/canvas@0.1.95)(@types/express@5.0.6)(audio-decode@2.2.3)(jimp@1.6.0)(node-llama-cpp@3.16.2(typescript@5.9.3))
|
||||
|
||||
extensions/huggingface: {}
|
||||
|
||||
@ -430,7 +430,7 @@ importers:
|
||||
dependencies:
|
||||
openclaw:
|
||||
specifier: '>=2026.3.11'
|
||||
version: 2026.3.13(@napi-rs/canvas@0.1.95)(@types/express@5.0.6)(audio-decode@2.2.3)(jimp@1.6.0)(node-llama-cpp@3.16.2(typescript@5.9.3))
|
||||
version: 2026.3.13(@discordjs/opus@0.10.0)(@napi-rs/canvas@0.1.95)(@types/express@5.0.6)(audio-decode@2.2.3)(jimp@1.6.0)(node-llama-cpp@3.16.2(typescript@5.9.3))
|
||||
|
||||
extensions/memory-lancedb:
|
||||
dependencies:
|
||||
@ -7482,7 +7482,7 @@ snapshots:
|
||||
dependencies:
|
||||
css-tree: 3.2.1
|
||||
|
||||
'@buape/carbon@0.0.0-beta-20260216184201(hono@4.12.8)(opusscript@0.1.1)':
|
||||
'@buape/carbon@0.0.0-beta-20260216184201(@discordjs/opus@0.10.0)(hono@4.12.8)(opusscript@0.1.1)':
|
||||
dependencies:
|
||||
'@types/node': 25.5.0
|
||||
discord-api-types: 0.38.37
|
||||
@ -12403,11 +12403,11 @@ snapshots:
|
||||
ws: 8.19.0
|
||||
zod: 4.3.6
|
||||
|
||||
openclaw@2026.3.13(@napi-rs/canvas@0.1.95)(@types/express@5.0.6)(audio-decode@2.2.3)(jimp@1.6.0)(node-llama-cpp@3.16.2(typescript@5.9.3)):
|
||||
openclaw@2026.3.13(@discordjs/opus@0.10.0)(@napi-rs/canvas@0.1.95)(@types/express@5.0.6)(audio-decode@2.2.3)(jimp@1.6.0)(node-llama-cpp@3.16.2(typescript@5.9.3)):
|
||||
dependencies:
|
||||
'@agentclientprotocol/sdk': 0.16.1(zod@4.3.6)
|
||||
'@aws-sdk/client-bedrock': 3.1009.0
|
||||
'@buape/carbon': 0.0.0-beta-20260216184201(hono@4.12.8)(opusscript@0.1.1)
|
||||
'@buape/carbon': 0.0.0-beta-20260216184201(@discordjs/opus@0.10.0)(hono@4.12.8)(opusscript@0.1.1)
|
||||
'@clack/prompts': 1.1.0
|
||||
'@discordjs/voice': 0.19.2(@discordjs/opus@0.10.0)(opusscript@0.1.1)
|
||||
'@grammyjs/runner': 2.0.3(grammy@1.41.1)
|
||||
|
||||
@ -167,6 +167,8 @@ export function resolveMemoryFlushContextWindowTokens(params: {
|
||||
);
|
||||
}
|
||||
|
||||
const _warnedReserve = new Set<string>();
|
||||
|
||||
export function shouldRunMemoryFlush(params: {
|
||||
entry?: Pick<
|
||||
SessionEntry,
|
||||
@ -197,9 +199,18 @@ export function shouldRunMemoryFlush(params: {
|
||||
return false;
|
||||
}
|
||||
const contextWindow = Math.max(1, Math.floor(params.contextWindowTokens));
|
||||
const reserveTokens = Math.max(0, Math.floor(params.reserveTokensFloor));
|
||||
const softThreshold = Math.max(0, Math.floor(params.softThresholdTokens));
|
||||
const threshold = Math.max(0, contextWindow - reserveTokens - softThreshold);
|
||||
const rawReserve = Math.max(0, Math.floor(params.reserveTokensFloor));
|
||||
const maxReserve = Math.max(0, contextWindow - softThreshold - 1);
|
||||
const warnKey = `${rawReserve}:${maxReserve}`;
|
||||
if (rawReserve > maxReserve && !_warnedReserve.has(warnKey)) {
|
||||
_warnedReserve.add(warnKey);
|
||||
console.warn(
|
||||
`reserveTokensFloor (${rawReserve}) exceeds contextWindow - softThreshold - 1 (${maxReserve}), clamping to ${maxReserve}`,
|
||||
);
|
||||
}
|
||||
const reserveTokens = Math.min(rawReserve, maxReserve);
|
||||
const threshold = contextWindow - reserveTokens - softThreshold;
|
||||
if (threshold <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -357,6 +357,17 @@ describe("shouldRunMemoryFlush", () => {
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("triggers when reserveTokensFloor equals contextWindowTokens", () => {
|
||||
expect(
|
||||
shouldRunMemoryFlush({
|
||||
entry: { totalTokens: 199_000, compactionCount: 0 },
|
||||
contextWindowTokens: 200_000,
|
||||
reserveTokensFloor: 200_000,
|
||||
softThresholdTokens: 4_000,
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("hasAlreadyFlushedForCurrentCompaction", () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user