atles / docs /bugs /MEMORY_NOT_SAVING_FIX.md
spartan8806's picture
ATLES codebase - Source code only
99b8067

Memory Not Saving Fix - Import Path Conflict

Issue

Despite active conversations, no new episode files were being created in atles_memory/episodes/.

Root Cause

Two versions of unified_memory_manager.py existed:

  1. βœ… Real version: atles/unified_memory_manager.py - Full functional memory system
  2. ❌ Stub version: atles_app/atles/unified_memory_manager.py - Simplified placeholder

The Problem

Python's import system was finding the stub version first due to import path ordering:

# In atles_desktop_pyqt.py:
from atles.unified_memory_manager import UnifiedMemoryManager

# Python searched:
# 1. atles_app/atles/unified_memory_manager.py ❌ FOUND (stub)
# 2. atles/unified_memory_manager.py βœ… (never reached)

Evidence

User's logs showed:

INFO: Using Unified Episodic & Semantic Memory System

But the stub version logged:

logger.info("Unified Memory Manager initialized (simplified mode)")

And its methods did nothing:

def add_message(self, sender: str, message: str, memory_type: str = "episodic"):
    """Add a message to memory."""
    logger.info(f"Adding to memory (simplified mode): {memory_type}")
    # ❌ NO ACTUAL SAVING!
    return True

The Fix

Modified the desktop app to add parent directory to path BEFORE importing:

# In atles_app/atles_desktop_pyqt.py - ConversationMemoryManager.__init__()
# Add parent directory to sys.path first
parent_dir = Path(__file__).parent.parent
if str(parent_dir) not in sys.path:
    sys.path.insert(0, str(parent_dir))

# Now import works correctly - gets real system from atles/
from atles.unified_memory_manager import UnifiedMemoryManager, get_unified_memory

Deleted the conflicting stub:

βœ… DELETED: atles_app/atles/unified_memory_manager.py (stub that was blocking imports)

This ensures:

  • βœ… Python can find atles/ package from atles_app/
  • βœ… Real memory system is imported
  • βœ… No circular import issues

Verification

Before Fix ❌

atles_memory/episodes/
└── episode_20250919_223218_71474982.json (last episode - old date)

No new episodes being created despite active conversations!

After Fix βœ…

Restart the desktop app and have a conversation. New episode files should appear:

atles_memory/episodes/
β”œβ”€β”€ episode_20250919_223218_71474982.json (old)
└── episode_20251114_[timestamp]_[hash].json (NEW!)

You should also see in logs:

βœ… Memory integration system initialized
Started conversation session: session_20251114_HHMMSS
Ended conversation session: episode_20251114_HHMMSS_[hash]

Related Files

  • βœ… Real memory system: atles/unified_memory_manager.py
  • βœ… Memory integration: atles/memory_integration.py
  • βœ… Episodic system: atles/episodic_semantic_memory.py
  • βœ… Desktop app: atles_app/atles_desktop_pyqt.py (modified to add parent dir to path)
  • ❌ DELETED: atles_app/atles/unified_memory_manager.py (stub removed)

Impact

Aspect Before After
New episodes saved ❌ No βœ… Yes
Session tracking ❌ Stub βœ… Real
Memory search ❌ Empty βœ… Functional
Learning from conversations ❌ Lost βœ… Retained

Testing

  1. Restart ATLES desktop app
  2. Have a conversation (5+ messages)
  3. Close the conversation (to trigger save)
  4. Check atles_memory/episodes/ for new files

Expected:

episode_20251114_193000_a1b2c3d4.json (NEW!)

Lessons Learned

Why This Happened

The stub was created as a temporary placeholder during refactoring but:

  1. ❌ Never removed after real system was built
  2. ❌ Same filename caused import conflict
  3. ❌ Python silently used wrong version

Prevention

  1. βœ… Never create stubs with same name as real modules
  2. βœ… Use .stub.py or _placeholder.py suffix
  3. βœ… Add clear warnings in stub files
  4. βœ… Remove stubs immediately after real implementation

Date Fixed: November 14, 2025
Status: RESOLVED βœ…
Action Required: Restart desktop app to use real memory system