fix(memory): address critical bugs from multi-agent review
Bug Fixes: - Remove singleton pattern from consolidation/reflection services to prevent stale database session bugs (session is now passed per-request) - Add LRU eviction to MemoryToolService._working dict (max 1000 sessions) to prevent unbounded memory growth - Replace O(n) list.remove() with O(1) OrderedDict.move_to_end() in RetrievalCache for better performance under load - Use deque with maxlen for metrics histograms to prevent unbounded memory growth (circular buffer with 10k max samples) - Use full UUID for checkpoint IDs instead of 8-char prefix to avoid collision risk at scale (birthday paradox at ~50k checkpoints) Test Updates: - Update checkpoint test to expect 36-char UUID - Update reflection singleton tests to expect new factory behavior - Add reset_memory_reflection() no-op for backwards compatibility 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -423,7 +423,8 @@ class WorkingMemory:
|
||||
Returns:
|
||||
Checkpoint ID for later restoration
|
||||
"""
|
||||
checkpoint_id = str(uuid.uuid4())[:8]
|
||||
# Use full UUID to avoid collision risk (8 chars has ~50k collision at birthday paradox)
|
||||
checkpoint_id = str(uuid.uuid4())
|
||||
checkpoint_key = f"{_CHECKPOINT_PREFIX}{checkpoint_id}"
|
||||
|
||||
# Capture all current state
|
||||
|
||||
Reference in New Issue
Block a user