oraios/serena · error · FileNotFoundError
Memory named '{name}' not found
Error message
Memory named '{name}' not found What it means
load_memory raises FileNotFoundError when no memory file exists at the resolved path for the given (sanitized) name. The name passed validation, but there is simply no such memory in the project or global memories directory.
Source
Thrown at src/serena/memories/memory_manager.py:209
# Strip "global/" prefix and resolve against global dir
sub_name = name[len(self.GLOBAL_TOPIC) + 1 :]
return self._resolve_memory_path(self._global_memory_dir, sub_name.split("/"))
# Project-local memory
assert self._project_memory_dir is not None, "Project dir was not passed at initialization"
return self._resolve_memory_path(self._project_memory_dir, parts)
def _check_write_access(self, name: str, is_tool_context: bool) -> None:
# in tool context, memories can be read-only
if is_tool_context and self._is_read_only_memory(name):
raise PermissionError(f"Attempted to write to read_only memory: '{name}')")
def load_memory(self, name: str) -> str:
name = self._sanitize_name(name)
self._check_not_ignored(name)
memory_file_path = self.get_memory_file_path(name)
if not memory_file_path.exists():
raise FileNotFoundError(f"Memory named '{name}' not found")
with open(memory_file_path, encoding=self._encoding) as f:
return f.read()
def save_memory(self, name: str, content: str, is_tool_context: bool) -> str:
name = self._sanitize_name(name)
self._check_not_ignored(name)
self._check_write_access(name, is_tool_context)
memory_file_path = self.get_memory_file_path(name)
with open(memory_file_path, "w", encoding=self._encoding) as f:
f.write(content)
return f"Memory {name} written."
class MemoriesList:
def __init__(self) -> None:
self.memories: list[str] = []
self.read_only_memories: list[str] = []
def __len__(self) -> int:View on GitHub (pinned to 7fcbca7e62)
Solutions
- List available memories first (list_memories) and use an exact existing name.
- Check the name's spelling and structure: no '.md' suffix needed (it is stripped), use 'global/<name>' for global memories.
- Create the memory with save_memory if it should exist.
- If it was renamed, use the new name (rename tools update references in other memories).
Example fix
// before
content = manager.load_memory("coding_convention") # typo
// after
names = manager.list_memories()
content = manager.load_memory("coding_conventions") # exact match from list Defensive patterns
Strategy: try-catch
Validate before calling
names = manager.list_memories()
if name not in names:
raise KeyError(f"memory {name!r} not found; available: {names}") Type guard
def memory_exists(manager, name: str) -> bool:
return manager.get_memory_file_path(name).exists() Try / catch
try:
content = manager.load_memory(name)
except FileNotFoundError:
log.warning("memory %r missing; creating empty", name)
manager.save_memory(name, "", is_tool_context=False)
content = "" Prevention
- Always list_memories and pick exact names before reading
- Remember _sanitize_name strips 'mem:' and '.md'; don't double-apply them
- Update prompts/references after renames so stale names aren't reused
When it happens
Trigger: Calling load_memory with a name that was never created via save_memory, was deleted, was renamed/moved elsewhere, or is subtly misspelled ('-' vs '_', missing topic prefix, wrong global/ path).
Common situations: Agents guessing memory names from project descriptions; referencing a memory after rename_memory_and_propagate_references changed its name; switching projects where the memory only exists globally (or vice versa); stale prompts referencing deleted memories.
Related errors
- Bare "{self.GLOBAL_TOPIC}" is not a valid memory name. Use "
- Memory {old_name} not found.
- Project '{project_name}' not found in Serena configuration;
- Memory '{name}' matches an ignored_memory_patterns pattern a
- Attempted to write to read_only memory: '{name}')
AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29).
Data as JSON: /api/errors/6ec9c7970db55258.
Report an issue: GitHub.