Skip to content

fix: advance last_consolidated on consolidation failure to prevent re…#1691

Open
TTdogCC wants to merge 1 commit intoHKUDS:mainfrom
TTdogCC:fix/memory-consolidation-last-consolidated
Open

fix: advance last_consolidated on consolidation failure to prevent re…#1691
TTdogCC wants to merge 1 commit intoHKUDS:mainfrom
TTdogCC:fix/memory-consolidation-last-consolidated

Conversation

@TTdogCC
Copy link
Copy Markdown

@TTdogCC TTdogCC commented Mar 8, 2026

…try storm

Root cause analysis of loop.py / memory.py:

When memory consolidation fails (LLM timeout or error), last_consolidated was not updated, causing the next trigger to retry an ever-growing batch. This leads to unbounded message accumulation and cascading LLM timeouts.

Specifically:

  • last_consolidated is only updated on success — if the LLM call fails, it stays at the old position
  • The trigger condition len(session.messages) > self.memory_window keeps firing every message once exceeded
  • Result: 76 → 240 message accumulation observed in a single session, causing downstream LLM timeouts on the main agent loop

Fix: In the except block of _consolidate_memory, advance last_consolidated to the current position even on failure, matching the success-path logic. The if not archive_all guard ensures the /new command path is unaffected.

Note: concurrency guards (self._consolidating set + task lock) were already in place in loop.py.

Fixes #1174

…try storm

When memory consolidation fails (LLM timeout or error), last_consolidated
was not updated, causing the next trigger to retry an ever-growing batch.
This leads to unbounded message accumulation and cascading LLM timeouts.

Fixes HKUDS#1174
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: memory consolidation can take long or even fail

1 participant