Skip to content

Conversation

@nkanu17
Copy link
Collaborator

@nkanu17 nkanu17 commented Dec 15, 2025

Issue #449

In redisvl/extensions/message_history/schema.py, the ChatMessage class generates IDs using only the session tag and timestamp:
values[ID_FIELD_NAME] = f"{values[SESSION_FIELD_NAME]}:{values[TIMESTAMP_FIELD_NAME]}"

When multiple messages are added rapidly (e.g., via add_messages(messages) or store(prompt, response)), they can receive the same timestamp, resulting in identical IDs. Since Redis uses these IDs as keys, newer messages overwrite older ones with the same ID, causing message loss.

Fix:

  • Add UUID suffix to ChatMessage entry_id to ensure uniqueness
  • Update ID format from 'session:timestamp' to 'session:timestamp:uuid'
  • Add test for rapid message creation with same timestamp

- Add UUID suffix to ChatMessage entry_id to ensure uniqueness
- Update ID format from 'session:timestamp' to 'session:timestamp:uuid'
- Add test for rapid message creation with same timestamp
- Fixes #449"
Copilot AI review requested due to automatic review settings December 15, 2025 22:35
Copy link
Collaborator

@justin-cechmanek justin-cechmanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@nkanu17 nkanu17 merged commit caa9621 into main Dec 15, 2025
44 checks passed
Copy link
Collaborator

@abrookins abrookins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

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.

4 participants