From e7f2204a07d5d472516a5d47a5187164757cc298 Mon Sep 17 00:00:00 2001 From: iamagenius00 Date: Tue, 28 Apr 2026 01:38:30 +0800 Subject: [PATCH] fix(compression): reset _last_summary_error at start of compress() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The per-call reset block at the top of compress() cleared _last_summary_dropped_count and _last_summary_fallback_used but not _last_summary_error. Functionally this didn't break the gateway warning path (callers gate on _last_summary_fallback_used first, and _last_summary_error is overwritten on the next failure), but it left the three tracking fields inconsistent — anyone reading _last_summary_error standalone after a successful compress would see a stale value from a previous failed compress. Reset all three together so the per-call contract is uniform. --- agent/context_compressor.py | 1 + 1 file changed, 1 insertion(+) diff --git a/agent/context_compressor.py b/agent/context_compressor.py index 2c87309ae..5cbb133d7 100644 --- a/agent/context_compressor.py +++ b/agent/context_compressor.py @@ -1207,6 +1207,7 @@ The user has requested that this compaction PRIORITISE preserving all informatio # after compress() returns to decide whether to surface a warning. self._last_summary_dropped_count = 0 self._last_summary_fallback_used = False + self._last_summary_error = None n_messages = len(messages) # Only need head + 3 tail messages minimum (token budget decides the real tail size) _min_for_compress = self.protect_first_n + 3 + 1