fix(context_compactor): return original messages when compaction summary fails (#2174)

On summary LLM call failure, maybe_compact was returning system_msgs+recent
(dropping the older half) with was_compacted=False, misleading the caller into
thinking the list was unchanged. Return the original messages list unchanged so
no history is lost; the next trim_for_context call handles length if needed.

Fixes #2160

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
max-freddyfire
2026-06-07 16:40:16 +02:00
committed by GitHub
parent c75d3e1975
commit 43c16fc7e4
2 changed files with 101 additions and 1 deletions
+4 -1
View File
@@ -381,7 +381,10 @@ async def maybe_compact(
)
except Exception as e:
logger.error(f"Compaction summary failed: {e}")
return system_msgs + recent, context_length, False
# Degrade gracefully: keep the conversation intact rather than
# silently dropping the older half. was_compacted=False signals the
# caller nothing was summarized; trim_for_context handles length.
return messages, context_length, False
summary_msg = {
"role": "system",