Skip to content

fix: make lancedb optional dependency under [memory] extras#5801

Open
NIK-TIGER-BILL wants to merge 7 commits into
crewAIInc:mainfrom
NIK-TIGER-BILL:fix-lancedb-optional-5327
Open

fix: make lancedb optional dependency under [memory] extras#5801
NIK-TIGER-BILL wants to merge 7 commits into
crewAIInc:mainfrom
NIK-TIGER-BILL:fix-lancedb-optional-5327

Conversation

@NIK-TIGER-BILL
Copy link
Copy Markdown
Contributor

@NIK-TIGER-BILL NIK-TIGER-BILL commented May 13, 2026

Description

Moves lancedb>=0.29.2 from core dependencies to [project.optional-dependencies] memory group. This unblocks installation on Intel Macs where lancedb has no x86_64 wheels (see #5327).

Changes

  • pyproject.toml: Removed lancedb>=0.29.2 from dependencies, added [memory] optional dependency group.
  • lancedb_storage.py: Wrapped import lancedb in a try/except block. LanceDBStorage.__init__ now raises a clear ImportError pointing users to pip install crewai[memory].

Impact

  • pip install crewai no longer requires lancedb — works on Intel Macs.
  • Users who need memory features install with pip install crewai[memory].
  • Existing Apple Silicon and Linux users are unaffected.

Related Issue

Fixes #5327

Summary by CodeRabbit

Release Notes

  • Documentation

    • Clarified default flow persistence file name and platform-specific storage locations
    • Updated persistence example to demonstrate proper state resumption with explicit ID passing
  • Bug Fixes

    • Fixed tool execution to correctly mark results as errors when tool exceptions occur
  • Chores

    • Improved optional dependency handling with clearer installation prompts for memory storage features

Review Change Stack

NIK-TIGER-BILL and others added 7 commits May 1, 2026 23:15
When a tool with result_as_answer=True raises an exception, the agent
was receiving result_as_answer=True and returning the error string as
the final answer. Now we set result_as_answer=False when an error event
is emitted, allowing the agent to reflect and retry.

Fixes crewAIInc#5156

Signed-off-by: NIK-TIGER-BILL <[email protected]>
Signed-off-by: NIK-TIGER-BILL <[email protected]>
The class-level @persist() example claimed that state is
"automatically loaded" on the second run, but  only
restores persisted state when an explicit  is
provided. Update the docs example to pass the previous flow's
state id so the second run actually demonstrates resumed state.

Fixes crewAIInc#5378

Signed-off-by: NIK-TIGER-BILL <[email protected]>
Moves lancedb>=0.29.2 from core dependencies to [project.optional-dependencies]
memory group. This unblocks installation on Intel Macs where lancedb has no
x86_64 wheels.

- lancedb_storage.py now gracefully handles ImportError with a clear message
pointing users to install crewai[memory]

Fixes crewAIInc#5327

Signed-off-by: NIK-TIGER-BILL <[email protected]>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

📝 Walkthrough

Walkthrough

This PR addresses a critical installation blocker by making lancedb an optional dependency, refines tool execution semantics to prevent incorrect result flags on errors, and clarifies flow persistence documentation with platform-specific storage details and corrected state resumption examples.

Changes

crewAI Library Improvements

Layer / File(s) Summary
Optional lancedb dependency and lazy loading
lib/crewai/pyproject.toml, lib/crewai/src/crewai/memory/storage/lancedb_storage.py
Moves lancedb from mandatory core dependency to optional [memory] extras group. LanceDBStorage now uses lazy import with try/except, raising an informative ImportError with install hint (pip install crewai[memory]) when the dependency is unavailable.
Tool error handling refinement
lib/crewai/src/crewai/utilities/agent_utils.py, lib/crewai/tests/utilities/test_agent_utils.py
execute_single_native_tool_call now sets result_as_answer only when the tool indicates result_as_answer AND no error event was emitted. New test verifies that tool errors with result_as_answer=True return result_as_answer=False with error details.
Flow persistence documentation
docs/en/concepts/flows.mdx, docs/en/guides/flows/mastering-flow-state.mdx
Documented SQLite backend filename (flow_states.db), platform-specific storage paths (Linux, macOS, Windows), default project-name behavior, and CREWAI_STORAGE_DIR override. Updated state resumption example to explicitly pass flow1.state.id into kickoff.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • crewAIInc/crewAI#5779: Related to the updated flow state example; that PR discusses deprecation of inputs.id hydration in favor of restoreFromStateId.

Suggested labels

size/M

Suggested reviewers

  • greysonlalonde
  • vinibrsl

Poem

🐰 A lancedb made optional, Intel Macs now sing,
Tool errors caught with care, no false flags take wing,
Persistence paths revealed for all to see,
State flows resume with explicit ID—crispy! 🌰✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Out of Scope Changes check ❓ Inconclusive Documentation and test changes appear tangential to the core lancedb dependency fix; clarification needed on whether updating flow persistence docs and tool error handling tests are necessary scope for this PR. Confirm whether documentation updates (flows.mdx, mastering-flow-state.mdx) and the tool error handling test are intentional dependencies of the lancedb optional-dependency fix or should be in separate PRs.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: make lancedb optional dependency under [memory] extras' accurately summarizes the main objective of moving lancedb from core dependencies to optional dependencies.
Linked Issues check ✅ Passed The pull request fully addresses issue #5327 by making lancedb an optional dependency under [memory] extras, ensuring crewai is installable on Intel Macs while allowing opt-in for memory features.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch fix-lancedb-optional-5327

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/crewai/src/crewai/utilities/agent_utils.py`:
- Around line 1595-1600: The current is_result_as_answer flag only checks
original_tool.result_as_answer and error_event_emitted, allowing tools marked
result_as_answer to be treated as final even when the tool was blocked or not
found; modify the condition in the is_result_as_answer assignment to also
require overall successful execution by negating the relevant failure flags —
e.g., include checks like not tool_blocked and not tool_not_found (or a single
execution_succeeded flag if present) so the final expression becomes something
like: original_tool and hasattr(original_tool, "result_as_answer") and
original_tool.result_as_answer and not error_event_emitted and not tool_blocked
and not tool_not_found.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c233a85e-0765-4c49-ae66-b064e9976853

📥 Commits

Reviewing files that changed from the base of the PR and between c36827b and cec692d.

📒 Files selected for processing (6)
  • docs/en/concepts/flows.mdx
  • docs/en/guides/flows/mastering-flow-state.mdx
  • lib/crewai/pyproject.toml
  • lib/crewai/src/crewai/memory/storage/lancedb_storage.py
  • lib/crewai/src/crewai/utilities/agent_utils.py
  • lib/crewai/tests/utilities/test_agent_utils.py

Comment on lines 1595 to 1600
is_result_as_answer = bool(
original_tool
and hasattr(original_tool, "result_as_answer")
and original_tool.result_as_answer
and not error_event_emitted
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Guard result_as_answer on overall execution success, not only emitted error events.

At Line 1599, tool-blocked and tool-not-found paths still allow result_as_answer=True for tools configured with result_as_answer, which can incorrectly finalize with an error/block message.

Proposed fix
+    execution_failed = hook_blocked or error_event_emitted or (
+        not from_cache and func_name not in available_functions
+    )
+
     is_result_as_answer = bool(
         original_tool
         and hasattr(original_tool, "result_as_answer")
         and original_tool.result_as_answer
-        and not error_event_emitted
+        and not execution_failed
     )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/crewai/src/crewai/utilities/agent_utils.py` around lines 1595 - 1600, The
current is_result_as_answer flag only checks original_tool.result_as_answer and
error_event_emitted, allowing tools marked result_as_answer to be treated as
final even when the tool was blocked or not found; modify the condition in the
is_result_as_answer assignment to also require overall successful execution by
negating the relevant failure flags — e.g., include checks like not tool_blocked
and not tool_not_found (or a single execution_succeeded flag if present) so the
final expression becomes something like: original_tool and
hasattr(original_tool, "result_as_answer") and original_tool.result_as_answer
and not error_event_emitted and not tool_blocked and not tool_not_found.

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.

[BUG] crewai 1.12.2 uninstallable on Intel Macs: mandatory lancedb>=0.29.2 dependency has no macOS x86_64 wheels

2 participants