mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 04:43:43 +00:00
fix: update compaction safeguard to respect context window tokens
This commit is contained in:
@@ -195,11 +195,15 @@ export default function compactionSafeguardExtension(api: ExtensionAPI): void {
|
||||
}
|
||||
|
||||
try {
|
||||
const contextWindowTokens = resolveContextWindowTokens(model);
|
||||
const runtime = getCompactionSafeguardRuntime(ctx.sessionManager);
|
||||
const modelContextWindow = resolveContextWindowTokens(model);
|
||||
const contextWindowTokens = Math.min(
|
||||
runtime?.contextWindowTokens ?? modelContextWindow,
|
||||
modelContextWindow,
|
||||
);
|
||||
const turnPrefixMessages = preparation.turnPrefixMessages ?? [];
|
||||
let messagesToSummarize = preparation.messagesToSummarize;
|
||||
|
||||
const runtime = getCompactionSafeguardRuntime(ctx.sessionManager);
|
||||
const maxHistoryShare = runtime?.maxHistoryShare ?? 0.5;
|
||||
|
||||
const tokensBefore =
|
||||
|
||||
Reference in New Issue
Block a user