mirror of
https://github.com/wassname/pi-auto-compressor.git
synced 2026-06-27 16:46:09 +08:00
feat: Add early trigger, update state logic and README.md
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user