diff --git a/README.md b/README.md index 6056b90a..f6caedbb 100644 --- a/README.md +++ b/README.md @@ -596,6 +596,7 @@ Here is the full list of Serena's tools with a short description (output of `uv * `read_memory`: Reads the memory with the given name from Serena's project-specific memory store. * `replace_lines`: Replaces a range of lines within a file with new content. * `replace_symbol_body`: Replaces the full definition of a symbol. +* `restart_language_server`: Restarts the language server, may be necessary when edits not through Serena happen. * `search_in_all_code`: Performs a search for a pattern in all code files (and only in code files) in the project. * `summarize_changes`: Provides instructions for summarizing the changes made to the codebase. * `think_about_collected_information`: Thinking tool for pondering the completeness of collected information. diff --git a/src/serena/agent.py b/src/serena/agent.py index e13b1afb..19a0ab56 100644 --- a/src/serena/agent.py +++ b/src/serena/agent.py @@ -502,6 +502,20 @@ class ToolMarkerDoesNotRequireActiveProject: pass +class RestartLanguageServerTool(Tool): + """Restarts the language server, may be necessary when edits not through Serena happen.""" + + def apply(self) -> str: + """Use this tool only on explicit user request or after confirmation. + It may be necessary to restart the language server if the user performs edits + not through Serena, so the language server state becomes outdated and further editing attempts lead to errors. + + If such editing errors happen, you should suggest using this tool. + """ + self.agent.reset_language_server() + return "OK" + + class ReadFileTool(Tool): """ Reads a file within the project directory.