fix(compression): reset failure cooldown on runtime switch
This commit is contained in:
parent
c201b72f34
commit
bcce700783
|
|
@ -1175,6 +1175,9 @@ class ContextCompressor(ContextEngine):
|
|||
if runtime_changed:
|
||||
self._fallback_compression_streak = 0
|
||||
self._persist_fallback_compression_streak()
|
||||
# Failure cooldowns are scoped to the model/provider that failed.
|
||||
# A switch must give the new runtime an immediate summary attempt.
|
||||
self._clear_compression_failure_cooldown()
|
||||
self._verify_compaction_cleared_threshold = False
|
||||
self._last_compression_made_progress = False
|
||||
|
||||
|
|
@ -1260,7 +1263,6 @@ class ContextCompressor(ContextEngine):
|
|||
return max(1, min(int(effective_window * ContextCompressor._MIN_CTX_TRIGGER_RATIO),
|
||||
effective_window - 1))
|
||||
return floored
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
model: str,
|
||||
|
|
|
|||
|
|
@ -3039,6 +3039,31 @@ class TestUpdateModelResetsCalibration:
|
|||
assert comp.should_defer_preflight_to_real_usage(comp.threshold_tokens + 5_000) is False
|
||||
|
||||
|
||||
def test_summary_failure_cooldown_cleared(self):
|
||||
"""Stale summary-failure cooldown from the old model must not block
|
||||
the new model from generating summaries after a switch."""
|
||||
import time
|
||||
comp = self._comp()
|
||||
# Simulate a 600-second cooldown set because the old model had no
|
||||
# provider configured for summarization.
|
||||
comp._summary_failure_cooldown_until = time.monotonic() + 600
|
||||
|
||||
comp.update_model("new-model", context_length=128_000)
|
||||
|
||||
assert comp._summary_failure_cooldown_until == 0.0
|
||||
|
||||
def test_summary_failure_cooldown_survives_same_runtime_refresh(self):
|
||||
"""Refreshing metadata for the same runtime must not defeat backoff."""
|
||||
import time
|
||||
comp = self._comp()
|
||||
cooldown_until = time.monotonic() + 600
|
||||
comp._summary_failure_cooldown_until = cooldown_until
|
||||
|
||||
comp.update_model("big-model", context_length=128_000)
|
||||
|
||||
assert comp._summary_failure_cooldown_until == cooldown_until
|
||||
|
||||
|
||||
class TestTruncateToolCallArgsJson:
|
||||
"""Regression tests for #11762.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue