fix: remove double safety margin in proactive compaction
Safety margin was applied twice: 1. threshold = (context - reserve) / 1.2 2. estimated = (existing + prompt) * 1.2 This caused compaction to trigger too early (~62% instead of ~83%). Now only applied once in threshold calculation.
This commit is contained in:
parent
3bf63a89e9
commit
f28dacc11b
@ -110,8 +110,8 @@ export async function checkProactiveCompaction(params: {
|
||||
// Add estimate for the new prompt (default ~500 tokens if not provided)
|
||||
const promptEstimate = params.promptTokenEstimate ?? 500;
|
||||
|
||||
// Apply safety margin to account for estimation inaccuracy
|
||||
const estimatedTotalTokens = Math.floor((existingTokens + promptEstimate) * SAFETY_MARGIN);
|
||||
// Total estimated tokens (safety margin is already applied in threshold calculation)
|
||||
const estimatedTotalTokens = existingTokens + promptEstimate;
|
||||
|
||||
const shouldCompact = estimatedTotalTokens >= threshold;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user