fix: make lancedb optional dependency under [memory] extras#5801
fix: make lancedb optional dependency under [memory] extras#5801NIK-TIGER-BILL wants to merge 7 commits into
Conversation
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]>
…c#5372) Signed-off-by: NIK-TIGER-BILL <[email protected]>
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]>
📝 WalkthroughWalkthroughThis 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. ChangescrewAI Library Improvements
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (6)
docs/en/concepts/flows.mdxdocs/en/guides/flows/mastering-flow-state.mdxlib/crewai/pyproject.tomllib/crewai/src/crewai/memory/storage/lancedb_storage.pylib/crewai/src/crewai/utilities/agent_utils.pylib/crewai/tests/utilities/test_agent_utils.py
| 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 | ||
| ) |
There was a problem hiding this comment.
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.
Description
Moves
lancedb>=0.29.2from core dependencies to[project.optional-dependencies] memorygroup. This unblocks installation on Intel Macs where lancedb has no x86_64 wheels (see #5327).Changes
lancedb>=0.29.2fromdependencies, added[memory]optional dependency group.import lancedbin atry/exceptblock.LanceDBStorage.__init__now raises a clearImportErrorpointing users topip install crewai[memory].Impact
pip install crewaino longer requires lancedb — works on Intel Macs.pip install crewai[memory].Related Issue
Fixes #5327
Summary by CodeRabbit
Release Notes
Documentation
Bug Fixes
Chores