From 6b88f46c54ac6e43a8a1ba40b7f5175cc7be5f7f Mon Sep 17 00:00:00 2001 From: pander <> Date: Mon, 27 Apr 2026 00:03:25 +0800 Subject: [PATCH] fix(compressor): trigger fallback on timeout errors alongside model-not-found Previously only HTTP 404/503 and specific error strings triggered a fallback to the main model when the summary model was unavailable. Timeout errors (HTTP 408/429/502/504, or error strings containing 'timeout') entered a short cooldown instead, leaving context to grow unbounded for the rest of the session. Add _is_timeout detection alongside _is_model_not_found so that transient timeout errors on the summary model also trigger immediate fallback to the main model, preventing compression failure from cascading. Closes #15935 --- agent/context_compressor.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/agent/context_compressor.py b/agent/context_compressor.py index 6c177b9099..44d54d530c 100644 --- a/agent/context_compressor.py +++ b/agent/context_compressor.py @@ -906,15 +906,19 @@ The user has requested that this compaction PRIORITISE preserving all informatio or "does not exist" in _err_str or "no available channel" in _err_str ) + _is_timeout = ( + _status in (408, 429, 502, 504) + or "timeout" in _err_str + ) if ( - _is_model_not_found + (_is_model_not_found or _is_timeout) and self.summary_model and self.summary_model != self.model and not getattr(self, "_summary_model_fallen_back", False) ): self._summary_model_fallen_back = True logging.warning( - "Summary model '%s' not available (%s). " + "Summary model '%s' unavailable (%s). " "Falling back to main model '%s' for compression.", self.summary_model, e, self.model, )