diff --git a/src/serena/agent.py b/src/serena/agent.py index f3c4d6ab..694320e3 100644 --- a/src/serena/agent.py +++ b/src/serena/agent.py @@ -876,6 +876,13 @@ class SerenaAgent: """ return self._active_tools.contains_tool_name(tool_name) + def tool_is_exposed(self, tool_name: str) -> bool: + """ + :param tool_name: the name of the tool to check + :return: True if the tool is in the exposed tool set, False otherwise + """ + return self._exposed_tools.contains_tool_name(tool_name) + def get_current_config_overview(self) -> str: """ :return: a string overview of the current configuration, including the active and available configuration options diff --git a/src/serena/tools/workflow_tools.py b/src/serena/tools/workflow_tools.py index e8bc67b4..7b1f5d96 100644 --- a/src/serena/tools/workflow_tools.py +++ b/src/serena/tools/workflow_tools.py @@ -4,7 +4,7 @@ Tools supporting the general workflow of the agent import platform -from serena.tools import Tool, ToolMarkerDoesNotRequireActiveProject +from serena.tools import ReadMemoryTool, Tool, ToolMarkerDoesNotRequireActiveProject, WriteMemoryTool class CheckOnboardingPerformedTool(Tool): @@ -17,12 +17,16 @@ class CheckOnboardingPerformedTool(Tool): Checks whether project onboarding was already performed. You should always call this tool before beginning to actually work on the project/after activating a project. """ + read_memory_tool_available = self.agent.tool_is_exposed(ReadMemoryTool.get_name_from_cls()) + perform_onboarding_tool_available = self.agent.tool_is_exposed(OnboardingTool.get_name_from_cls()) + + if not read_memory_tool_available: + return "Memory reading tool not activated, skipping onboarding check." project_memories = self.memories_manager.list_project_memories() if len(project_memories) == 0: - msg = ( - "Onboarding not performed yet (no memories available). " - "You should perform onboarding by calling the `onboarding` tool before proceeding with the task. " - ) + msg = "Onboarding not performed yet (no memories available). " + if perform_onboarding_tool_available: + msg += "You should perform onboarding by calling the `onboarding` tool before proceeding with the task. " else: # Not reporting the list of memories here, as they were already reported at project activation # (with the system prompt if the project was activated at startup) @@ -46,6 +50,9 @@ class OnboardingTool(Tool): :return: instructions on how to create the onboarding information """ + write_memory_tool_available = self.agent.tool_is_exposed(WriteMemoryTool.get_name_from_cls()) + if not write_memory_tool_available: + return "Memory writing tool not activated, skipping onboarding." system = platform.system() return self.prompt_factory.create_onboarding_prompt(system=system)