[P0] Call clear_stale_conversations() in Sleep Phase #7

Closed
opened 2025-12-05 13:48:53 +00:00 by blightbow · 1 comment
Owner

Problem

clear_stale_conversations() exists but is never called. This leads to:

  • Unbounded conversation_history growth
  • Memory bloat over time

Suggested Fix

Add call to run_dreaming_tick() after entity consolidation.

Priority

P0 — Immediate (Blocks Production)

Source

Architecture Audit 2025-12-03, Section 2: Memory Leak Potential

## Problem `clear_stale_conversations()` exists but is **never called**. This leads to: - Unbounded `conversation_history` growth - Memory bloat over time ## Suggested Fix Add call to `run_dreaming_tick()` after entity consolidation. ## Priority **P0 — Immediate (Blocks Production)** ## Source Architecture Audit 2025-12-03, Section 2: Memory Leak Potential
Author
Owner

Resolution

Added clear_stale_conversations() call to the dreaming phase in run_sleep_tick().

Changes

rag_memory.py (lines 866-876):

  • Added import and call to clear_stale_conversations(character) after episodic pruning
  • Returns cleared count in results dict as stale_conversations_cleared
  • Logs cleanup activity when conversations are cleared
  • Updated phase message to reflect "memory cleanup" operations

test_working_memory.py:

  • Added TestClearStaleConversationsIntegration test class
  • Source inspection test verifies the call exists in run_sleep_tick

Dreaming Phase Cleanup Order

  1. run_dreaming_tick() - A-MEM memory link generation
  2. run_entity_consolidation_batch() - O-Mem entity consolidation
  3. check_reflection_trigger() / run_reflection() - Generative Agents insights
  4. prune_low_importance_entries() - Episodic memory pruning
  5. clear_stale_conversations() - Working memory cleanup (NEW)

This prevents unbounded growth of active_conversations in working memory.

## Resolution Added `clear_stale_conversations()` call to the dreaming phase in `run_sleep_tick()`. ### Changes **rag_memory.py** (lines 866-876): - Added import and call to `clear_stale_conversations(character)` after episodic pruning - Returns cleared count in results dict as `stale_conversations_cleared` - Logs cleanup activity when conversations are cleared - Updated phase message to reflect "memory cleanup" operations **test_working_memory.py**: - Added `TestClearStaleConversationsIntegration` test class - Source inspection test verifies the call exists in `run_sleep_tick` ### Dreaming Phase Cleanup Order 1. `run_dreaming_tick()` - A-MEM memory link generation 2. `run_entity_consolidation_batch()` - O-Mem entity consolidation 3. `check_reflection_trigger()` / `run_reflection()` - Generative Agents insights 4. `prune_low_importance_entries()` - Episodic memory pruning 5. **`clear_stale_conversations()`** - Working memory cleanup (NEW) This prevents unbounded growth of `active_conversations` in working memory.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
blightbow/evennia_ai#7
No description provided.