Repository navigation
Python: fix(python): Fix VolatileMemoryStore.get_nearest_matches on empty collection - #14565
Conversation
|
Jeevan Babu Gotru (@jeevan1098) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix correctly addresses the reported failure and includes adequate regression coverage.
0 open findings
What changed in this PR
Fixes empty VolatileMemoryStore searches so they return no matches instead of raising a NumPy reshape error.
Changes:
- Adds an early return for empty collections.
- Adds coverage for empty, missing, and populated collections.
| File | Description |
|---|---|
python/semantic_kernel/memory/volatile_memory_store.py |
Handles empty collections safely. |
python/tests/unit/memory/test_volatile_memory_store.py |
Tests nearest-match behavior across collection states. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@microsoft-github-policy-service agree |
Fixes #14534
Problem
VolatileMemoryStore.get_nearest_matchesraisedValueError: cannot reshape array of size 0 into shape (0,newaxis)when the collection existed but had no records. This crashedSemanticTextMemory.searchandTextMemoryPlugin.recallon freshly created or emptied collections, instead of returning no results.Fix
Return
[]early when the collection has no records, matching the existing behavior for missing collections.Tests
Added
python/tests/unit/memory/test_volatile_memory_store.pywith tests for empty collection, missing collection, and correct ranking with records. All 3 pass.