Repository navigation
test(memory): add async parity and restart-persistence contract tests - #8893
Conversation
Strix Security ReviewWarning This pull request has 66 commits after the last Strix review ( ✅ No open security findings. PR summary: Adds two test-only files that verify the memory `StorageBackend` contract: record lifecycle and pagination across LanceDB and Qdrant Edge, plus async (`asave`/`asearch`/`adelete`) parity with the sync API, restart persistence, and dimension-mismatch error behavior. No production code changes. Review summaryBoth changed files are new pytest suites under Review 1 on this PR · Reviewed by Strix |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 978aeea. Configure here.
Run one suite against LanceDB and Qdrant Edge that checks asave/asearch/ adelete match their sync counterparts on isolated stores, that records survive closing and reopening a store, and that dimension mismatches are raised explicitly without touching stored data. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
a564e5a to
d19600f
Compare
Thanks for your first contribution to CrewAI, Aadesh Salecha (@AadeshSalecha)!We really appreciate the time and care you put into this PR. Your work is now part of CrewAI — welcome to the contributor community. Want to share your contribution? Totally optional: Share on X · Share the PR on LinkedIn If the links don't work, feel free to copy and personalize this: If you share, we'd love to see it — tag crewAI (@crewAIInc) on X and CrewAI on LinkedIn. |

Related issue
Fixes #8137
Part of #8120. Builds on the shared backend fixtures from #8135 (merged in #8222).
Summary
The
StorageBackendcontract declaresasave/asearch/adelete, but nothing checked that they behave likesave/search/delete, or that records written to a local store are still there after reopening it.test_storage_backend_async_parity.pyruns one suite against LanceDB and Qdrant Edge, reusing_record,_assert_same_record,VECTOR_DIMand the backend params fromtest_storage_backend_contract.py. Runtime code is unchanged.TestAsyncParity): astorage_pairfixture opens two isolated stores of the same backend undertmp_path; one is driven through the sync API and the other through the async API, so no store or lock is shared. Comparesasavevssave(ids, fields, list order),asearchvssearchacross six filter combinations (ids, scores, fields), andadeletevsdeleteacross seven selectors (record_ids,scope_prefix,categories,metadata_filter,older_than, scope+categories, everything) with an exact deletion count and identical remaining ids. Also covers the empty-store case.TestRestartPersistence): closes the store and reopens the same path, then checks every record field,list_recordsorder, scope and category counts,list_scopes,get_scope_info, search results, records written throughasave, update-and-delete outcomes, and that reopening withvector_dim=Noneinfers the dimension from the existing store.TestStorageErrors):EmbeddingDimensionMismatchErrorfromsave/asave,search/asearch, a mixed-dimension batch (nothing written) andupdate(original record preserved); assertsstored_dim/new_dimand that it is aValueErrorbut not aRuntimeError, asbackend.pydocuments.Out of scope: locking, multi-process access, or same-store sync/async interleaving. Parity is checked on separate stores on purpose.
Verification
Tests added or updated for the changed behavior
Relevant tests and quality checks pass locally
uv run pytest lib/crewai/tests/memory/test_storage_backend_async_parity.py -q: 50 passed on both backends (qdrant-edge-pyinstalled viauv sync --all-groups --all-extras).uv run pytest lib/crewai/tests/memory -qon currentmain: 277 passed.ruff check,ruff format --diff(with--no-force-exclude, since the ruff config excludeslib/crewai/tests/) andmypy --follow-imports=silenton the new file: clean. Pre-commit hooks pass.No paid API calls; fixed 4-dim vectors and temporary stores only.
Additional context
Rebased onto
mainafter #8222 merged; the PR is now a single commit adding one test file. Authored with an AI coding agent (Factory Droid), hence thellm-generatedlabel request.Note
Low Risk
Test-only addition with no production code changes; expands coverage for memory storage backends.
Overview
Adds
test_storage_backend_async_parity.py, a single new test module with no runtime changes. It parametrizes LanceDB and Qdrant Edge using helpers fromtest_storage_backend_contractand locks in three contracts:Async parity runs sync and async APIs on isolated twin stores so
asave/asearch/adeletematchsave/search/delete(filters, deletion selectors, empty store).Restart persistence closes and reopens the same path and asserts records, scope/category views, search results, async saves, updates/deletes, and
vector_dim=Nonereopen inferring dimension from the store.Storage errors asserts
EmbeddingDimensionMismatchErroron sync/async save and search, mixed batches writing nothing, and failed updates leaving data intact.Concurrency and same-store interleaving are explicitly out of scope.
Reviewed by Cursor Bugbot for commit db6b5c0. Bugbot is set up for automated code reviews on this repo. Configure here.