fix: make lancedb an optional dependency under [memory] extras#5328
fix: make lancedb an optional dependency under [memory] extras#5328devin-ai-integration[bot] wants to merge 3 commits intomainfrom
Conversation
Moves lancedb from core dependencies to optional [memory] extras group in pyproject.toml. This unblocks installation on Intel Macs where lancedb>=0.29.2 has no macOS x86_64 wheels. - Add try/except around lancedb import in lancedb_storage.py - Raise clear ImportError with install instructions when lancedb is absent - Add 6 tests covering optional dependency behavior - Existing memory tests continue to pass Closes #5327 Co-Authored-By: João <joao@crewai.com>
|
Prompt hidden (unlisted session) |
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7bec692. Configure here.
| mod.LanceDBStorage(path=str(tmp_path / "mem")) | ||
|
|
||
| # Restore the module to its original state | ||
| importlib.reload(mod) |
There was a problem hiding this comment.
Test module restoration happens inside patched context
Low Severity
The importlib.reload(mod) calls intended to "restore the module to its original state" execute inside the with patch.dict(sys.modules, {"lancedb": None}) block. Since sys.modules["lancedb"] is still None during the reload, the module's lancedb variable remains None after the test. This causes test pollution — subsequent tests in the same session that use LanceDBStorage will see lancedb as None and fail unexpectedly.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 7bec692. Configure here.
Co-Authored-By: João <joao@crewai.com>
…move unused assignment ignore Co-Authored-By: João <joao@crewai.com>


Summary
Moves
lancedbfrom a mandatory core dependency to an optional[memory]extras group (pip install crewai[memory]). This fixes #5327 —lancedb>=0.29.2dropped macOS x86_64 (Intel) wheels, makingcrewaicompletely uninstallable on all Intel Macs, even for projects that never use memory features.Changes:
lib/crewai/pyproject.toml: Removedlancedbfrom core deps, added newmemory = ["lancedb>=0.29.2,<0.30.1"]optional extras grouplancedb_storage.py: Wrappedimport lancedbin try/except;LanceDBStorage.__init__raises a clearImportErrorwith install instructions when lancedb is absentReview & Testing Checklist for Human
pip install crewaiwill no longer includelancedb. Users must switch topip install crewai[memory]. Verify this tradeoff is acceptable vs. a deprecation warning period.storage="lancedb"by default: AnyFlowsubclass will hit the newImportErrorat runtime if lancedb is not installed, even if the user never callsremember()/recall(). Consider whether the default should change to a no-op or lazy check only when memory is actually used.pip install crewai[memory].pip install crewaisucceeds on macOS x86_64 without lancedb, andpip install crewai[memory]still works on supported platforms.Notes
memory_tui.pyandunified_memory.pyalready use lazy/guarded imports ofLanceDBStorage, so theImportErrorfromlancedb_storage.pypropagates naturally through existing error paths.uv.lockdiff is auto-generated from the pyproject.toml change.Link to Devin session: https://app.devin.ai/sessions/e6e9627734c640b7a42ec4c85d5ab96f
Note
Medium Risk
Changes packaging so
lancedbis no longer installed by default, which can break runtime for users relying on the defaultMemory(storage='lancedb')unless they add the newcrewai[memory]extra. Runtime impact is limited to memory/LanceDB usage and now fails fast with a clear ImportError.Overview
Makes
lancedban optional dependency by moving it from core requirements to a newmemoryextra (pip install crewai[memory]), and updatesuv.lockaccordingly.Updates
LanceDBStorageto tolerate missinglancedbat import time and to raise a clearImportErrorwith installation instructions when instantiated. Adds tests ensuringcrewaican be imported withoutlancedb, memory initialization fails with the expected message when LanceDB is selected, and custom storage backends don’t requirelancedb.Reviewed by Cursor Bugbot for commit da4b610. Bugbot is set up for automated code reviews on this repo. Configure here.