Skip to content

Conversation

@vedant381
Copy link
Contributor

@vedant381 vedant381 commented Oct 28, 2025

The _get_all_from_vector_store and _aget_all_from_vector_store methods now normalize varied return formats from vector stores (list, tuple, nested list) and handle None values to prevent crashes. Added a parameterized test suite to validate the fix against multiple data structure scenarios.

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #3674
This pull request improves the robustness of the memory retrieval logic by normalizing the output from the vector store, ensuring consistent handling of various return types. It also adds comprehensive tests to verify this normalization across multiple scenarios.

Improvements to memory retrieval robustness:

  • Updated both the synchronous and asynchronous versions of _get_all_from_vector_store in mem0/memory/main.py to normalize the return value from the vector store. Now, the method handles cases where the result could be a tuple containing a list, a list of lists, or other nested structures, ensuring actual_memories is always a flat list. [1] [2]
  • Modified the loop over actual_memories to safely handle cases where it may be None or empty, preventing errors during iteration. [1] [2]

Testing enhancements:

  • Added a parameterized test test_get_all_handles_various_return_types in tests/test_memory.py to cover all expected return types from the vector store, including flat lists, tuples, nested lists, empty lists, and None. This ensures the normalization logic works as intended for all supported scenarios.

Type of change

Please delete options that are not relevant.

  • 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?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Please delete options that are not relevant.

  • Unit Test
  • Test Script (please provide)

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

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Made sure Checks passed

The _get_all_from_vector_store and _aget_all_from_vector_store methods now normalize varied return formats from vector stores (list, tuple, nested list) and handle None values to prevent crashes. Added a parameterized test suite to validate the fix against multiple data structure scenarios.
@vedant381 vedant381 closed this Nov 1, 2025
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.

500 Internal Server Error on /memories endpoint

1 participant