crewAIInc / crewAIInc/crewAI

[BUG] MemorySlice.recall ignores its scope argument

Open Beginner friendly
#7,532 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
58.8k
Forks
8.5k
Avg merge
1d 15h
Merged PRs (30d)
109

Description

Description

MemorySlice.recall() accepts a scope argument but does not apply it. Each delegated recall always receives only the slice root.

For example, recalling scope="/project" from a slice over [/team, /company] currently searches /team and /company, rather than narrowing the searches to /team/project and /company/project.

This differs from MemoryScope.recall() and the other MemorySlice query methods, which treat a supplied path as relative to the view's root(s).

Steps to Reproduce
from unittest.mock import MagicMock

from crewai.memory.memory_scope import MemorySlice

memory = MagicMock()
memory.recall.return_value = []
view = MemorySlice(memory=memory, scopes=["/team", "/company"])

view.recall("query", scope="/project", depth="shallow")

print([call.kwargs["scope"] for call in memory.recall.call_args_list])

Current result:

['/team', '/company']
Expected behavior

The requested scope should narrow every slice root:

['/team/project', '/company/project']

None and / should keep the existing behavior of searching each full slice root.

Screenshots/Code snippets

MemorySlice.recall() currently delegates with scope=sc, leaving its own scope parameter unused.

Operating System

macOS (15.5)

Python Version

3.13

crewAI Version

Current main at 5c33fe4c713a.

crewAI Tools Version

1.15.22

Virtual Environment

Venv (uv)

Evidence

The behavior is present in the original MemorySlice.recall() implementation and is not covered by the existing slice recall test, which does not pass scope.

The intended relative-path behavior is already established by:

  • MemoryScope.recall()
  • Memory.root_scope
  • MemorySlice.list_scopes(), info(), and list_categories()
  • the documented definition of a slice as a view over restricted branches

Targeted searches for MemorySlice recall scope and the affected symbol found no matching open issue or pull request.

Possible Solution

Compose each slice root with the requested scope using the existing join_scope_paths() helper before delegating to Memory.recall(). Add regression coverage for multiple roots, the / root, leading-slash and relative inputs, and None// defaults.

Additional context

AI-assisted report and proposed fix. Please apply the required llm-generated label; external contributors do not have permission to add repository labels directly.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in crewai/memory/memory_scope.py at MemorySlice.recall() and inspect the existing join_scope_paths() helper and MemoryScope.recall() behavior. Run the existing slice recall test, then add regression coverage for multiple roots, relative and leading-slash scopes, /, and None. Done means delegated calls use the narrowed roots while / and None preserve full-root searches.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
85/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.