mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-02 15:52:34 +00:00
feat: update lancedb version and add lance-namespace packages
* chore(deps): update lancedb version and add lance-namespace packages - Updated lancedb dependency version from 0.4.0 to 0.29.2 in multiple files. - Added new packages: lance-namespace and lance-namespace-urllib3-client with version 0.5.2, including their dependencies and installation details. - Enhanced MemoryTUI to display a limit on entries and improved the LanceDBStorage class with automatic background compaction and index creation for better performance. * linter * refactor: update memory recall limit and formatting in Agent class - Reduced the memory recall limit from 10 to 5 in multiple locations within the Agent class. - Updated the memory formatting to use a new `format` method in the MemoryMatch class for improved readability and metadata inclusion. * refactor: enhance memory handling with read-only support - Updated memory-related classes and methods to support read-only functionality, allowing for silent no-ops when attempting to remember data in read-only mode. - Modified the LiteAgent and CrewAgentExecutorMixin classes to check for read-only status before saving memories. - Adjusted MemorySlice and Memory classes to reflect changes in behavior when read-only is enabled. - Updated tests to verify that memory operations behave correctly under read-only conditions. * test: set mock memory to read-write in unit tests - Updated unit tests in test_unified_memory.py to set mock_memory._read_only to False, ensuring that memory operations can be tested in a writable state. * fix test * fix: preserve falsy metadata values and fix remember() return type --------- Co-authored-by: lorenzejay <lorenzejaytech@gmail.com> Co-authored-by: Greyson LaLonde <greyson@crewai.com>
This commit is contained in:
@@ -1136,6 +1136,7 @@ def test_lite_agent_memory_instance_recall_and_save_called():
|
||||
successful_requests=1,
|
||||
)
|
||||
mock_memory = Mock()
|
||||
mock_memory._read_only = False
|
||||
mock_memory.recall.return_value = []
|
||||
mock_memory.extract_memories.return_value = ["Fact one.", "Fact two."]
|
||||
|
||||
|
||||
@@ -218,14 +218,15 @@ def test_memory_slice_recall(tmp_path: Path, mock_embedder: MagicMock) -> None:
|
||||
assert isinstance(matches, list)
|
||||
|
||||
|
||||
def test_memory_slice_remember_raises_when_read_only(tmp_path: Path, mock_embedder: MagicMock) -> None:
|
||||
def test_memory_slice_remember_is_noop_when_read_only(tmp_path: Path, mock_embedder: MagicMock) -> None:
|
||||
from crewai.memory.unified_memory import Memory
|
||||
from crewai.memory.memory_scope import MemorySlice
|
||||
|
||||
mem = Memory(storage=str(tmp_path / "db7"), llm=MagicMock(), embedder=mock_embedder)
|
||||
sl = MemorySlice(mem, ["/a"], read_only=True)
|
||||
with pytest.raises(PermissionError):
|
||||
sl.remember("x", scope="/a")
|
||||
result = sl.remember("x", scope="/a")
|
||||
assert result is None
|
||||
assert mem.list_records() == []
|
||||
|
||||
|
||||
# --- Flow memory ---
|
||||
@@ -318,6 +319,7 @@ def test_executor_save_to_memory_calls_extract_then_remember_per_item() -> None:
|
||||
from crewai.agents.parser import AgentFinish
|
||||
|
||||
mock_memory = MagicMock()
|
||||
mock_memory._read_only = False
|
||||
mock_memory.extract_memories.return_value = ["Fact A.", "Fact B."]
|
||||
|
||||
mock_agent = MagicMock()
|
||||
@@ -358,6 +360,7 @@ def test_executor_save_to_memory_skips_delegation_output() -> None:
|
||||
from crewai.utilities.string_utils import sanitize_tool_name
|
||||
|
||||
mock_memory = MagicMock()
|
||||
mock_memory._read_only = False
|
||||
mock_agent = MagicMock()
|
||||
mock_agent.memory = mock_memory
|
||||
mock_agent._logger = MagicMock()
|
||||
|
||||
Reference in New Issue
Block a user