fix(context_compressor): off-by-one in tail protection for short conversations

This commit is contained in:
0z! 2026-04-28 16:43:55 +03:00 committed by Teknium
parent 2997ef9446
commit b194617d00

View File

@ -538,7 +538,7 @@ class ContextCompressor(ContextEngine):
# Token-budget approach: walk backward accumulating tokens # Token-budget approach: walk backward accumulating tokens
accumulated = 0 accumulated = 0
boundary = len(result) boundary = len(result)
min_protect = min(protect_tail_count, len(result) - 1) min_protect = min(protect_tail_count, len(result))
for i in range(len(result) - 1, -1, -1): for i in range(len(result) - 1, -1, -1):
msg = result[i] msg = result[i]
raw_content = msg.get("content") or "" raw_content = msg.get("content") or ""