oraios/serena · error · FileNotFoundError
Memory {old_name} not found.
Error message
Memory {old_name} not found. What it means
move_memory (rename) raises FileNotFoundError when the source memory file old_name does not exist. The move/rename cannot proceed because there is nothing to move; note write-access checks for both names run first.
Source
Thrown at src/serena/memories/memory_manager.py:337
memory_file_path.unlink()
return f"Memory {name} deleted."
def move_memory(self, old_name: str, new_name: str, is_tool_context: bool) -> str:
"""
Rename or move a memory file.
Moving between global and project scope (e.g. "global/foo" -> "bar") is supported.
"""
old_name = self._sanitize_name(old_name)
new_name = self._sanitize_name(new_name)
self._check_not_ignored(old_name)
self._check_not_ignored(new_name)
self._check_write_access(new_name, is_tool_context)
old_path = self.get_memory_file_path(old_name)
new_path = self.get_memory_file_path(new_name)
if not old_path.exists():
raise FileNotFoundError(f"Memory {old_name} not found.")
if new_path.exists():
raise FileExistsError(f"Memory {new_name} already exists.")
new_path.parent.mkdir(parents=True, exist_ok=True)
shutil.move(old_path, new_path)
return f"Memory renamed from {old_name} to {new_name}."
def rename_memory_and_propagate_references(self, old_name: str, new_name: str, is_tool_context: bool) -> tuple[str, int]:
"""
Renames a memory and updates every ``mem:OLD_NAME`` reference across all memories.
Memories whose content does not contain a reference to ``old_name`` are left
untouched (no spurious mtime changes). Memories that do are rewritten via
:meth:`save_memory`.
:param old_name: the current memory name (the source of the rename)
:param new_name: the target memory nameView on GitHub (pinned to 7fcbca7e62)
Solutions
- Verify the source exists via list_memories (or get_memory_file_path(...).exists()) before renaming.
- Use the exact current name including the 'global/' prefix for global memories.
- If it was already renamed, use the current name as old_name or treat the operation as complete.
- Recreate the source with save_memory if it was accidentally deleted and must be moved.
Example fix
// before
manager.move_memory("old_notes", "new_notes", is_tool_context=True) # FileNotFoundError
// after
if manager.get_memory_file_path("old_notes").exists():
manager.move_memory("old_notes", "new_notes", is_tool_context=True) Defensive patterns
Strategy: validation
Validate before calling
if not manager.get_memory_file_path(old_name).exists():
raise KeyError(f"cannot rename: source {old_name!r} does not exist") Type guard
def can_move(manager, old: str, new: str) -> bool:
return manager.get_memory_file_path(old).exists() and not manager.get_memory_file_path(new).exists() Try / catch
try:
manager.move_memory(old_name, new_name, is_tool_context)
except FileNotFoundError:
log.warning("source %r gone; skipping rename", old_name) Prevention
- Check source existence before every move/rename
- Use the correct scope prefix ('global/') for global memories
- Avoid double renames by tracking the current name after each operation
When it happens
Trigger: Calling move_memory(old_name, new_name, is_tool_context) where old_name was never created, was deleted, or is misspelled; also when old_name refers to a memory in the wrong scope (project vs global/<name>).
Common situations: Renaming after the memory was already renamed (double rename); agents hallucinating the source memory name; renaming a global memory without the 'global/' prefix (it exists only under the global dir).
Related errors
- Memory named '{name}' not found
- Memory {new_name} already exists.
- Project '{project_name}' not found in Serena configuration;
- Memory '{name}' matches an ignored_memory_patterns pattern a
- Bare "{self.GLOBAL_TOPIC}" is not a valid memory name. Use "
AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29).
Data as JSON: /api/errors/a62f3e6c445e403a.
Report an issue: GitHub.