diff --git a/holmes/config.py b/holmes/config.py index 0613831f1..b7abbbf5e 100644 --- a/holmes/config.py +++ b/holmes/config.py @@ -304,7 +304,10 @@ def get_runbook_catalog() -> Optional[RunbookCatalog]: return runbook_catalog def create_console_tool_executor( - self, dal: Optional["SupabaseDal"], refresh_status: bool = False + self, + dal: Optional["SupabaseDal"], + refresh_status: bool = False, + disable_todos: bool = False, ) -> ToolExecutor: """ Creates a ToolExecutor instance configured for CLI usage. This executor manages the available tools @@ -318,6 +321,13 @@ def create_console_tool_executor( cli_toolsets = self.toolset_manager.list_console_toolsets( dal=dal, refresh_status=refresh_status ) + + # Disable the core_investigation toolset (which contains TodoWriteTool) when in fast mode + if disable_todos: + cli_toolsets = [ + ts for ts in cli_toolsets if ts.name != "core_investigation" + ] + return ToolExecutor(cli_toolsets) def create_tool_executor(self, dal: Optional["SupabaseDal"]) -> ToolExecutor: @@ -343,8 +353,11 @@ def create_console_toolcalling_llm( dal: Optional["SupabaseDal"] = None, refresh_toolsets: bool = False, tracer=None, + disable_todos: bool = False, ) -> "ToolCallingLLM": - tool_executor = self.create_console_tool_executor(dal, refresh_toolsets) + tool_executor = self.create_console_tool_executor( + dal, refresh_toolsets, disable_todos + ) from holmes.core.tool_calling_llm import ToolCallingLLM return ToolCallingLLM( diff --git a/holmes/core/prompt.py b/holmes/core/prompt.py index af7ac61c4..b68c0ce99 100644 --- a/holmes/core/prompt.py +++ b/holmes/core/prompt.py @@ -54,6 +54,9 @@ def build_initial_ask_messages( runbooks: Optional runbook catalog system_prompt_additions: Optional additional system prompt content """ + # Check if todos are enabled by looking for core_investigation toolset + has_todos = any(ts.name == "core_investigation" for ts in tool_executor.toolsets) + # Load and render system prompt internally system_prompt_template = "builtin://generic_ask.jinja2" template_context = { @@ -61,6 +64,7 @@ def build_initial_ask_messages( "runbooks": runbooks or {}, "system_prompt_additions": system_prompt_additions or "", "investigation_id": investigation_id, + "has_todos": has_todos, } system_prompt_rendered = load_and_render_prompt( system_prompt_template, template_context diff --git a/holmes/main.py b/holmes/main.py index e7cad87f1..aa1bc396e 100644 --- a/holmes/main.py +++ b/holmes/main.py @@ -215,6 +215,11 @@ def ask( "--system-prompt-additions", help="Additional content to append to the system prompt", ), + fast: bool = typer.Option( + False, + "--fast", + help="Fast mode: disables todos tool for quicker responses", + ), ): """ Ask any question and answer using available tools @@ -252,6 +257,7 @@ def ask( dal=None, # type: ignore refresh_toolsets=refresh_toolsets, # flag to refresh the toolset status tracer=tracer, + disable_todos=fast, # disable todos tool when --fast is used ) if prompt_file and prompt: diff --git a/holmes/plugins/prompts/_general_instructions.jinja2 b/holmes/plugins/prompts/_general_instructions.jinja2 index d896743f3..3aeecd0aa 100644 --- a/holmes/plugins/prompts/_general_instructions.jinja2 +++ b/holmes/plugins/prompts/_general_instructions.jinja2 @@ -51,6 +51,7 @@ * For any question, try to make the answer specific to the user's cluster. ** For example, if asked to port forward, find out the app or pod port (kubectl describe) and provide a port forward command specific to the user's question +{% if has_todos %} # MANDATORY Task Management * You MUST use the TodoWrite tool for ANY investigation requiring multiple steps @@ -62,6 +63,7 @@ * Follow ALL tasks in your plan - don't skip any tasks * Use task management to ensure you don't miss important investigation steps * If you discover additional steps during investigation, add them to your task list using TodoWrite +{% endif %} # Tool/function calls