feat: Add early trigger, update state logic and README.md

This commit is contained in:
wassname
2026-04-23 13:50:22 +08:00
parent 277ae0132f
commit 7e76fe250c
4 changed files with 48 additions and 3 deletions
+5 -1
View File
@@ -358,7 +358,11 @@ export async function applyPruning(
AUTO_COMPRESS_CONFIG.minimumContextLength
);
if (totalTokens >= thresholdTokens && msgs.length > AUTO_COMPRESS_CONFIG.protectFirstN + 4) {
if (
state.forceCompressNext ||
(totalTokens >= thresholdTokens && msgs.length > AUTO_COMPRESS_CONFIG.protectFirstN + 4)
) {
state.forceCompressNext = false;
const tailBudget = Math.floor(thresholdTokens * AUTO_COMPRESS_CONFIG.summaryTargetRatio);
const compressStart = alignBoundaryForward(msgs, AUTO_COMPRESS_CONFIG.protectFirstN);
const compressEnd = findTailCutByTokens(msgs, compressStart, tailBudget);