镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

test(memory): add async parity and restart-persistence contract tests - #8893

Merged
Lorenze Jay (lorenzejay) merged 2 commits into
crewAIInc:mainfrom
AadeshSalecha:test/memory-backend-async-parity
Nov 10, 2026
Merged

Lorenze Jay (lorenzejay) merged 2 commits into
crewAIInc:mainfrom
AadeshSalecha:test/memory-backend-async-parity

Conversation

@AadeshSalecha

@AadeshSalecha Aadesh Salecha (AadeshSalecha) commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Related issue

Fixes #8137

Part of #8120. Builds on the shared backend fixtures from #8135 (merged in #8222).

Summary

The StorageBackend contract declares asave/asearch/adelete, but nothing checked that they behave like save/search/delete, or that records written to a local store are still there after reopening it. test_storage_backend_async_parity.py runs one suite against LanceDB and Qdrant Edge, reusing _record, _assert_same_record, VECTOR_DIM and the backend params from test_storage_backend_contract.py. Runtime code is unchanged.

  • Async parity (TestAsyncParity): a storage_pair fixture opens two isolated stores of the same backend under tmp_path; one is driven through the sync API and the other through the async API, so no store or lock is shared. Compares asave vs save (ids, fields, list order), asearch vs search across six filter combinations (ids, scores, fields), and adelete vs delete across 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.
  • Restart persistence (TestRestartPersistence): closes the store and reopens the same path, then checks every record field, list_records order, scope and category counts, list_scopes, get_scope_info, search results, records written through asave, update-and-delete outcomes, and that reopening with vector_dim=None infers the dimension from the existing store.
  • Explicit errors (TestStorageErrors): EmbeddingDimensionMismatchError from save/asave, search/asearch, a mixed-dimension batch (nothing written) and update (original record preserved); asserts stored_dim/new_dim and that it is a ValueError but not a RuntimeError, as backend.py documents.

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-py installed via uv sync --all-groups --all-extras).

  • uv run pytest lib/crewai/tests/memory -q on current main: 277 passed.

  • ruff check, ruff format --diff (with --no-force-exclude, since the ruff config excludes lib/crewai/tests/) and mypy --follow-imports=silent on the new file: clean. Pre-commit hooks pass.

  • No paid API calls; fixed 4-dim vectors and temporary stores only.

Additional context

Rebased onto main after #8222 merged; the PR is now a single commit adding one test file. Authored with an AI coding agent (Factory Droid), hence the llm-generated label 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 from test_storage_backend_contract and locks in three contracts:

Async parity runs sync and async APIs on isolated twin stores so asave/asearch/adelete match save/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=None reopen inferring dimension from the store.

Storage errors asserts EmbeddingDimensionMismatchError on 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.

@strix-security

strix-security Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Strix Security Review

Warning

This pull request has 66 commits after the last Strix review (978aeea). Strix has not reviewed these changes.
Automatic review on push is off for this repository. To review the latest changes, tag @strix-security in a comment, or turn on re-review on push.

✅ 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 summary

Both changed files are new pytest suites under lib/crewai/tests/memory/ — one shared StorageBackend contract suite and one async-parity/restart-persistence suite. No runtime code is modified: the tests only open temporary LanceDB and Qdrant Edge stores under tmp_path, write fixed 4-dimensional vectors, and assert on record round-trips, search/delete parity, error types, and reopen behavior. There is no user-controlled input, no shell or network execution, no credential or filesystem sink, so nothing in this diff introduces an exploitable security issue.

Review 1 on this PR · 978aeea · requested Nov 1 00:12 UTC when the PR was opened


Reviewed by Strix
Re-run review · Configure security review settings

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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>
@AadeshSalecha

Copy link
Copy Markdown
Contributor Author

Rebased onto main now that #8222 is in. The branch is down to one commit adding test_storage_backend_async_parity.py; the carried #8222 commits and the xfail fixup are gone. lib/crewai/tests/memory passes locally on current main (277 passed).

@lorenzejay
Lorenze Jay (lorenzejay) merged commit 1357d23 into crewAIInc:main Nov 10, 2026
57 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

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:

I just made my first contribution to @crewAIInc!

Excited to help build the future of AI agents with CrewAI.

https://github.com/crewAIInc/crewAI/pull/8893

#OpenSource #AI #CrewAI

If you share, we'd love to see it — tag crewAI (@crewAIInc) on X and CrewAI on LinkedIn.

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.

[FEATURE] Add memory backend async parity and restart-persistence contracts

2 participants