(messages: Message[], ctxWindow: number, threshold = 0.70)
| 196 | // |
| 197 | // Skipping one compaction is cheap: the caller keeps its messages and tries again next |
| 198 | // turn. Losing the conversation is not. |
| 199 | const summaryBody = summaryText.replace(SUMMARY_PREFIX, '').trim(); |
| 200 | if (summaryBody.length < MIN_SUMMARY_CHARS) { |
| 201 | logger.warn('Compaction produced an unusably short summary; keeping original messages', { |
| 202 | summaryChars: summaryBody.length, |
| 203 | minRequired: MIN_SUMMARY_CHARS, |
| 204 | turnsNotCompacted: turnsCompacted, |