LearnNewsExamplesServices
Frontmatter
id7865
titleRefactor Memory Core to use numeric timestamps for ChromaDB compatibility
stateClosed
labels
bugai
assigneestobiu
createdAtNov 22, 2025, 8:47 PM
updatedAtNov 22, 2025, 9:05 PM
githubUrlhttps://github.com/neomjs/neo/issues/7865
authortobiu
commentsCount2
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtNov 22, 2025, 9:05 PM

Refactor Memory Core to use numeric timestamps for ChromaDB compatibility

Closed v11.9.0 bugai
tobiu
tobiu commented on Nov 22, 2025, 8:47 PM

ChromaDB's $gt operator requires numeric operands and fails with string-based ISO timestamps. This prevents efficient range queries for session summarization, causing the findSessionsToSummarize method to fail or require inefficient full-table scans.

We need to refactor MemoryService and SessionService to store and query timestamps as numbers (milliseconds since epoch) instead of ISO strings.

Changes Required:

  1. Update MemoryService.addMemory to store timestamp as Date.now().
  2. Update SessionService.summarizeSession to store timestamp as Date.now().
  3. Update SessionService.findSessionsToSummarize to query using numeric timestamps.
tobiu added the bug label on Nov 22, 2025, 8:47 PM
tobiu added the ai label on Nov 22, 2025, 8:47 PM
tobiu assigned to @tobiu on Nov 22, 2025, 8:47 PM
tobiu referenced in commit ecda364 - "Refactor Memory Core to use numeric timestamps for ChromaDB compatibility #7865" on Nov 22, 2025, 9:03 PM
tobiu
tobiu Nov 22, 2025, 9:04 PM

Input from Neo Agent OS:

◆ Implemented the refactoring to use numeric timestamps (milliseconds since epoch) for both MemoryService (storage) and SessionService (querying/summarization).

Key Changes

  1. Storage: MemoryService.addMemory and SessionService.summarizeSession now store timestamp as a number (Date.now()).
  2. Querying: SessionService.findSessionsToSummarize now uses numeric comparisons for the 30-day window, resolving the ChromaDB $gt operator failure.

New Utility Scripts

Added two new scripts to ai/examples/ which should be highlighted in the release notes:

  • ai/examples/migrate_timestamps.mjs: A migration utility that scans all memories and summaries in ChromaDB and converts legacy ISO string timestamps to numbers. Critical for upgrading existing databases.
  • ai/examples/debug_session_state.mjs: A "Thick Client" diagnostic tool that directly accesses the Memory Core services to detect session drift (mismatches between raw memories and summaries) and verify system health.

Verification

Verified the fix using the debug script. The SessionService successfully self-healed on startup, detecting and summarizing previously un-queryable sessions.

tobiu
tobiu Nov 22, 2025, 9:05 PM
Image
Image
tobiu closed this issue on Nov 22, 2025, 9:05 PM
tobiu cross-referenced by #7876 on Nov 23, 2025, 12:34 PM