fix(gateway): persist session hygiene compression-failure cooldown to state DB (#74136) - #74417
Conversation
… state DB (NousResearch#74136) The session hygiene compression path tracked its per-session failure cooldown in an in-memory dict (self._hygiene_compression_failure_cooldowns). When the gateway restarts, that dict is lost, so the same failing compression is immediately re-triggered — wedging session storage. The state DB already has a persistent column (sessions.compression_failure_cooldown_until) and dedicated methods (record_/get_/clear_compression_failure_cooldown) in hermes_state.py, used by the in-conversation compression path (context_compressor.py) but not by the session hygiene path. Fix: - Replace the in-memory dict check with session_db.get_compression_failure_cooldown() so the cooldown survives gateway restarts. - Replace in-memory writes with session_db.record_compression_failure_cooldown() in both the timeout and abort paths. - Clean up the abort-path error handling to eliminate redundant reads. - Update tests to assert against session_db mock instead of the removed in-memory dict. Fixes NousResearch#74136
Duplicate of #74251 — both persist the session-hygiene compression-failure cooldown through SessionDB so a gateway restart cannot immediately re-trigger the failing path. |
|
Thanks for targeting the persistent cooldown mismatch. The premise remains valid on current main: hygiene still uses the process-local map at Problems
Suggested changes
Automated hermes-sweeper review. |
|
Closing as a duplicate of #74251, which was submitted earlier with the same fix (swap the in-memory Your test-update intent will be folded into that salvage. Thanks — premise fully confirmed on main. |
Problem
The session hygiene compression path tracked its per-session failure cooldown in an in-memory dict (
_hygiene_compression_failure_cooldowns) on the gateway process. When the gateway restarts, that dict is lost, so the same failing compression is immediately re-triggered on the next message - wedging session storage.The user-visible symptom: after a compression failure (timeout, API error, abort), every message across all sessions gets the "session storage could not be written" error. Restarting the gateway does not recover - it clears the in-memory cooldown and the cycle repeats.
Root Cause
The state DB already has a persistent column
sessions.compression_failure_cooldown_untiland full read/write/clear methods (record_compression_failure_cooldown/get_compression_failure_cooldown/clear_compression_failure_cooldowninhermes_state.py). The in-conversation compression path (agent/context_compressor.py) already uses these persistent methods correctly. But the session hygiene path ingateway/run.pyused its own in-memory dict instead - the two paths disagreed on durability.Fix
await session_db.get_compression_failure_cooldown(session_id), consistent with the in-conversation path.await session_db.record_compression_failure_cooldown(...).session_db._dbmocks instead of the removed in-memory dict.Fixes #74136