serena.tools.memory_tools#
Source code: serena/tools/memory_tools.py
- class WriteMemoryTool(agent)[source]#
Bases:
Tool,ToolMarkerCanEditWrite some information (utf-8-encoded) about this project that can be useful for future tasks to a memory in md format. The memory name should be meaningful.
- Parameters:
agent (SerenaAgent)
- apply(memory_name, content, max_chars=-1)[source]#
Write information about this project that can be useful for future tasks in md format. The name should be meaningful and can include “/” to organize into topics. If explicitly instructed, use the “global/” prefix for writing a memory that is shared across projects. References to other memories should be inside backticks and prefixed with mem:, e.g., mem:auth.
- Parameters:
memory_name (str) – memory name
content (str) – memory content, utf8-encoded
max_chars (int) – see other tools
- Return type:
str
- class ReadMemoryTool(agent)[source]#
Bases:
ToolReads the content of a memory file.
- Parameters:
agent (SerenaAgent)
- class ListMemoriesTool(agent)[source]#
Bases:
ToolLists available memories.
- Parameters:
agent (SerenaAgent)
- class DeleteMemoryTool(agent)[source]#
Bases:
Tool,ToolMarkerCanEditDelete a memory file.
- Parameters:
agent (SerenaAgent)
- class RenameMemoryTool(agent)[source]#
Bases:
Tool,ToolMarkerCanEditRenames or moves a memory, updating references that are marked with the mem: prefix.
- Parameters:
agent (SerenaAgent)
- apply(old_name, new_name)[source]#
Rename or move a memory, use “/” in the name to organize into topics. The “global” topic should only be used if explicitly instructed. References to other memories that are marked with the mem: prefix will be updated accordingly. References in read-only memories are not affected.
- Parameters:
old_name (str)
new_name (str)
- Return type:
str
- class EditMemoryTool(agent)[source]#
Bases:
Tool,ToolMarkerCanEditReplaces content matching a regular expression in a memory.
- Parameters:
agent (SerenaAgent)
- apply(memory_name, needle, repl, mode, allow_multiple_occurrences=False)[source]#
Replace content matching a regular expression in a memory.
- Parameters:
memory_name (str) – the name of the memory
needle (str) – the string or regex pattern to search for. In regex mode, be careful to not replace too much! If mode is “literal”, this string will be matched exactly. If mode is “regex”, this string will be treated as a regular expression (syntax of Python’s re module, with the MULTILINE and DOTALL flags enabled).
repl (str) – the replacement string (verbatim).
mode (Literal['literal', 'regex']) – either “literal” or “regex”, specifying how the needle parameter is to be interpreted.
allow_multiple_occurrences (bool) – whether to allow matching and replacing multiple occurrences. If false and multiple occurrences are found, an error will be returned.
- Return type:
str