oraios/serena · error · FileNotFoundError
Memory {name} not found.
Error message
Memory {name} not found. What it means
Raised by MemoryManager.edit_memory in src/serena/memories/memory_manager.py:397 when the memory file corresponding to the given name does not exist in the memories directory. Serena memories are stored as markdown files named after the sanitized memory name; editing requires the file to already exist (use save_memory/create to make a new one).
Source
Thrown at src/serena/memories/memory_manager.py:397
regex_multiline: bool = True,
) -> str:
"""
Edit a memory by replacing content matching a pattern.
:param name: the memory name
:param needle: the string or regex to search for
:param repl: the replacement string
:param mode: "literal" or "regex"
:param allow_multiple_occurrences:
:param is_tool_context: whether the call originates from a tool invocation (affects write-access checks)
:param regex_multiline: whether to apply multi-line regex matching, enabling the flags re.DOTALL and re.MULTILINE
"""
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)
if not memory_file_path.exists():
raise FileNotFoundError(f"Memory {name} not found.")
with open(memory_file_path, encoding=self._encoding) as f:
original_content = f.read()
replacer = ContentReplacer(mode=mode, allow_multiple_occurrences=allow_multiple_occurrences, regex_multiline=regex_multiline)
updated_content = replacer.replace(original_content, needle, repl)
with open(memory_file_path, "w", encoding=self._encoding) as f:
f.write(updated_content)
return f"Memory {name} edited successfully."
def validate_referential_integrity(
self, include_unmarked: bool = True, include_fuzzy_matching: bool = True
) -> ReferentialIntegrityReport:
"""
Validates referential integrity across this manager's memories.
Thin wrapper around :meth:`MemoryReferenceAnalyzer.validate_referential_integrity`;
see that method for the full description of behavior and parameters.
"""
return MemoryReferenceAnalyzer(self).validate_referential_integrity(View on GitHub (pinned to 7fcbca7e62)
Solutions
- Run list_memories() and use an exact memory name from the result, respecting sanitization rules
- Create the memory first with save_memory(name, ...) before editing it
- Check the .serena/memories/ directory manually to confirm the file still exists
Example fix
// before
manager.edit_memory('architectur', needle='old', repl='new', mode='literal', allow_multiple_occurrences=False, is_tool_context=True)
// after
if 'architecture' in manager.list_memories().get_full_list():
manager.edit_memory('architecture', needle='old', repl='new', mode='literal', allow_multiple_occurrences=False, is_tool_context=True) Defensive patterns
Strategy: validation
Validate before calling
if name not in manager.list_memories().get_full_list():
raise LookupError(f'Memory {name} does not exist; create it first') Try / catch
try:
manager.edit_memory(name, needle, repl, mode='literal', allow_multiple_occurrences=False, is_tool_context=True)
except FileNotFoundError:
manager.save_memory(name, default_content, is_tool_context=True) Prevention
- Always list memories before editing
- Create memories with save_memory before editing
- Do not manually delete files from .serena/memories/
- Use exact, unsanitized names from list_memories output
When it happens
Trigger: Calling edit_memory (or the edit_memory tool) with a memory name that was never saved, a name that differs from the sanitized on-disk name, or one that was previously deleted or renamed.
Common situations: Agents referencing a memory from memory list output after manual deletion from the .serena/memories/ folder; typos or case mismatches in the memory name; calling edit before create in an automation script.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Context file not found: {path.resolve()}
- Project configuration file not found: {yaml_path}
- Serena configuration file not found: {config_file_path}
- Error: Path does not exist: {project_root}
- Error: Path is not a directory: {project_root}
AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29).
Data as JSON: /api/errors/b61ba0bf38152c92.
Report an issue: GitHub.