Skip to content

fix: preserve latest SQLite messages on timestamp ties - #6431

Open
lntutor wants to merge 1 commit into
mem0ai:mainfrom
lntutor:fix/sqlite-message-order-6429
Open

fix: preserve latest SQLite messages on timestamp ties#6431
lntutor wants to merge 1 commit into
mem0ai:mainfrom
lntutor:fix/sqlite-message-order-6429

Conversation

@lntutor

@lntutor lntutor commented Jul 19, 2026

Copy link
Copy Markdown

Linked Issue

Closes #6429

Description

Messages saved in one batch share a timestamp. SQLite retention and retrieval now use rowid as a deterministic insertion-order tie-breaker, so batches over ten entries discard the oldest messages and get_last_messages() returns the latest entries chronologically.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature
  • Breaking change
  • Refactor
  • Documentation update

Breaking Changes

N/A

Test Coverage

  • Added/updated unit tests
  • Added/updated integration tests
  • Tested manually
  • No tests needed

hatch run dev_py_3_11:pytest tests/memory/test_storage.py -q: 17 passed.

Checklist

  • Code follows the project style guidelines
  • Self-review performed
  • Tests prove the fix
  • New and existing targeted tests pass locally
  • Documentation is not required for this internal storage fix

@CLAassistant

CLAassistant commented Jul 19, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@lntutor
lntutor force-pushed the fix/sqlite-message-order-6429 branch from 4a8669d to 01432ad Compare July 26, 2026 06:07
@github-actions github-actions Bot added the sdk-python Python SDK specific label Jul 26, 2026
@lntutor
lntutor force-pushed the fix/sqlite-message-order-6429 branch from 01432ad to 609bfa6 Compare July 30, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sdk-python Python SDK specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQLite message retention drops the newest message when a batch exceeds 10 entries

2 participants