The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(state): bump the summary-overload streak atomically
kshitijk4poor50066dda6e92
diff --git a/agent/context_compressor.py b/agent/context_compressor.pyindex bd9e7dc4b26..9aad076da7e 100644--- a/agent/context_compressor.py+++ b/agent/context_compressor.py@@ -2368,6 +2368,14 @@ class ContextCompressor(SummaryDispatchMixin, MicroCompactionMixin, ContextEngindef _persist_consecutive_overload_aborts(self) -> None:self._durable_write("set_compression_overload_streak", "compression overload streak", self._consecutive_overload_aborts)+ def _increment_consecutive_overload_aborts(self) -> None:+ """Count one overload abort. The bound row is bumped atomically and is authoritative, so two+ agents on one session cannot lose a strike; memory-only when unbound or the row is missing."""+ found, streak = self._durable_read(+ "increment_compression_overload_streak", "compression overload streak increment", int, 0,+ )+ self._consecutive_overload_aborts = streak if found and streak else self._consecutive_overload_aborts + 1+def _load_ineffective_compression_count(self) -> None:"""Load the durable anti-thrash strike count so a restart never disarms a guard."""self._load_durable("_ineffective_compression_count", "get_compression_ineffective_count", "compression ineffective count", int, 0)@@ -4160,8 +4168,7 @@ Write only the summary body. Do not include any preamble or prefix."""elif kind.empty_content:self._last_summary_empty_content_failure = Trueelif kind.overloaded:- self._consecutive_overload_aborts += 1- self._persist_consecutive_overload_aborts()+ self._increment_consecutive_overload_aborts()# Sustained-overload escalation (#123167): keep aborting only while a retry could still# succeed soon (#115906); once every recent attempt has aborted, stop treating the# overload as terminal so compress() commits the deterministic fallback instead ofdiff --git a/hermes_state_compression.py b/hermes_state_compression.pyindex 757099075a5..782351e1126 100644--- a/hermes_state_compression.py+++ b/hermes_state_compression.py@@ -448,6 +448,18 @@ class SessionCompressionMixin:if session_id:self._write_session_column("compression_overload_streak", session_id, max(0, int(streak)))+ def increment_compression_overload_streak(self, session_id: str) -> Optional[int]:+ """Atomically bump the overload streak and return the new value (None when no row).+ One UPDATE ... RETURNING, so concurrent agents on one session cannot lose a strike."""+ if not session_id:+ return None+ def _do(conn):+ row = conn.execute(+ "UPDATE sessions SET compression_overload_streak = compression_overload_streak + 1"+ " WHERE id = ? RETURNING compression_overload_streak", (session_id,)).fetchone()+ return None if row is None else int(row[0])+ return self._execute_write(_do)+def refresh_compression_lock(self, session_id: str, holder: str, ttl_seconds: float = 300.0) -> bool:"""Extend the compression lock lease if ``holder`` still owns it. Ownership is decided by ``holder``alone, deliberately NOT ``expires_at``: a live owner whose refresher stalled past its TTL must be