Skip to content

fix: add timestamps for DELETE operations in history#4492

Merged
kartik-mem0 merged 1 commit intomem0ai:mainfrom
VictorECDSA:fix-delete-timestamps
Mar 26, 2026
Merged

fix: add timestamps for DELETE operations in history#4492
kartik-mem0 merged 1 commit intomem0ai:mainfrom
VictorECDSA:fix-delete-timestamps

Conversation

@VictorECDSA
Copy link
Copy Markdown
Contributor

@VictorECDSA VictorECDSA commented Mar 23, 2026

  • Preserve original memory creation time in created_at field
  • Record deletion time in updated_at field
  • Apply fix to both sync and async versions
  • Add comprehensive test coverage for timestamp preservation

Fixes #4467

Description

This PR implements enhancement #4467 by adding proper timestamp handling for DELETE operations in memory history.

Problem: When memories are deleted, the original creation timestamp is lost because created_at is overwritten with deletion time, making historical analysis impossible.

Solution:

  • Preserve original memory creation time in created_at field
  • Record deletion time in updated_at field
  • Apply fix to both sync (_delete_memory) and async (_adelete_memory) versions

Impact:

  • Enables accurate historical analysis of deleted memories
  • Maintains temporal integrity of memory lifecycle
  • Allows tracking "how long did this memory exist before deletion"

Fixes #4467

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

Tested with the following scenario:

  • Environment: Mem0 v1.0.7, Python 3.13, Qdrant (local)
  • Test scenarios:
    1. Create memory → verify created_at is set correctly
    2. Delete memory → verify created_at is preserved, updated_at is updated to deletion time
    3. Query history → verify both timestamps are correct and different

Example test output:

# After creation
created_at: 2026-03-20 10:00:00
updated_at: 2026-03-20 10:00:00

# After deletion
created_at: 2026-03-20 10:00:00  # ✓ Preserved
updated_at: 2026-03-21 15:30:00  # ✓ Updated to deletion time
  • Unit Test (comprehensive test coverage added)
  • Test Script (manual verification performed)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Maintainer Checklist

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 23, 2026

CLA assistant check
All committers have signed the CLA.

@VictorECDSA
Copy link
Copy Markdown
Contributor Author

@CLAassistant check

1 similar comment
@VictorECDSA
Copy link
Copy Markdown
Contributor Author

@CLAassistant check

@VictorECDSA VictorECDSA force-pushed the fix-delete-timestamps branch from d663a80 to 180cf79 Compare March 23, 2026 03:50
@VictorECDSA
Copy link
Copy Markdown
Contributor Author

@CLAassistant check

utkarsh240799
utkarsh240799 previously approved these changes Mar 25, 2026
- Preserve original memory creation time in created_at field
- Record deletion time in updated_at field
- Apply fix to both sync and async versions
- Add comprehensive test coverage for timestamp preservation

Fixes mem0ai#4467
@utkarsh240799 utkarsh240799 force-pushed the fix-delete-timestamps branch from 5439d27 to 0cd4b15 Compare March 26, 2026 10:43
@kartik-mem0 kartik-mem0 merged commit 1aecfad into mem0ai:main Mar 26, 2026
6 of 7 checks passed
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.

Enhancement: Add Timestamp for DELETE Operations in History

4 participants