1111 CONST_AGENT_CONFIG_PATH_DIR_ENV_KEY ,
1212 CONST_AGENT_NAME ,
1313 CONST_AGENT_NAME_ENV_KEY ,
14+ CONST_DISABLE_PROMETHEUS_TOOLSET_ENV_KEY ,
15+ CONST_PRIVACY_NOTICE_BANNER ,
16+ CONST_PRIVACY_NOTICE_BANNER_ENV_KEY ,
1417)
1518from azure .cli .core .api import get_config_dir
1619from azure .cli .core .commands .client_factory import get_subscription_id
1720from knack .util import CLIError
1821
22+ from .error_handler import MCPError
1923from .prompt import AKS_CONTEXT_PROMPT_MCP , AKS_CONTEXT_PROMPT_TRADITIONAL
2024from .telemetry import CLITelemetryClient
21- from .error_handler import MCPError
25+
26+
27+ # NOTE(mainred): environment variables to disable prometheus toolset loading should be set before importing holmes.
28+ def customize_holmesgpt ():
29+ os .environ [CONST_DISABLE_PROMETHEUS_TOOLSET_ENV_KEY ] = "true"
30+ os .environ [CONST_AGENT_CONFIG_PATH_DIR_ENV_KEY ] = get_config_dir ()
31+ os .environ [CONST_AGENT_NAME_ENV_KEY ] = CONST_AGENT_NAME
32+ os .environ [CONST_PRIVACY_NOTICE_BANNER_ENV_KEY ] = CONST_PRIVACY_NOTICE_BANNER
2233
2334
2435# NOTE(mainred): holmes leverage the log handler RichHandler to provide colorful, readable and well-formatted logs
@@ -151,21 +162,19 @@ def aks_agent(
151162 :type use_aks_mcp: bool
152163 """
153164
154- with CLITelemetryClient ():
165+ with CLITelemetryClient () as telemetry :
155166 if sys .version_info < (3 , 10 ):
156167 raise CLIError (
157168 "Please upgrade the python version to 3.10 or above to use aks agent."
158169 )
170+ # customizing holmesgpt should called before importing holmes
171+ customize_holmesgpt ()
159172
160173 # Initialize variables
161174 interactive = not no_interactive
162175 echo = not no_echo_request
163176 console = init_log ()
164177
165- # Set environment variables for Holmes
166- os .environ [CONST_AGENT_CONFIG_PATH_DIR_ENV_KEY ] = get_config_dir ()
167- os .environ [CONST_AGENT_NAME_ENV_KEY ] = CONST_AGENT_NAME
168-
169178 # Detect and read piped input
170179 piped_data = None
171180 if not sys .stdin .isatty ():
@@ -265,7 +274,7 @@ def aks_agent(
265274 is_mcp_mode = current_mode == "mcp"
266275 if interactive :
267276 _run_interactive_mode_sync (ai , cmd , resource_group_name , name ,
268- prompt , console , show_tool_output , is_mcp_mode )
277+ prompt , console , show_tool_output , is_mcp_mode , telemetry )
269278 else :
270279 _run_noninteractive_mode_sync (ai , config , cmd , resource_group_name , name ,
271280 prompt , console , echo , show_tool_output , is_mcp_mode )
@@ -312,13 +321,15 @@ async def _setup_mcp_mode(mcp_manager, config_file: str, model: str, api_key: st
312321 :return: Enhanced Holmes configuration
313322 :raises: Exception if MCP setup fails
314323 """
324+ import tempfile
315325 from pathlib import Path
326+
316327 import yaml
317- import tempfile
318328 from holmes .config import Config
329+
319330 from .config_generator import ConfigurationGenerator
320- from .user_feedback import ProgressReporter
321331 from .error_handler import AgentErrorHandler
332+ from .user_feedback import ProgressReporter
322333
323334 # Ensure binary is available (download if needed)
324335 if not mcp_manager .is_binary_available () or not mcp_manager .validate_binary_version ():
@@ -602,7 +613,7 @@ def _build_aks_context(cluster_name, resource_group_name, subscription_id, is_mc
602613
603614
604615def _run_interactive_mode_sync (ai , cmd , resource_group_name , name ,
605- prompt , console , show_tool_output , is_mcp_mode ):
616+ prompt , console , show_tool_output , is_mcp_mode , telemetry ):
606617 """
607618 Run interactive mode synchronously - no event loop conflicts.
608619
@@ -617,6 +628,7 @@ def _run_interactive_mode_sync(ai, cmd, resource_group_name, name,
617628 :param console: Console object for output
618629 :param show_tool_output: Whether to show tool output
619630 :param is_mcp_mode: Whether running in MCP mode (affects prompt selection)
631+ :param telemetry: CLITelemetryClient instance for tracking events
620632 """
621633 from holmes .interactive import run_interactive_loop
622634
@@ -633,7 +645,8 @@ def _run_interactive_mode_sync(ai, cmd, resource_group_name, name,
633645 ai , console , prompt , None , None ,
634646 show_tool_output = show_tool_output ,
635647 system_prompt_additions = aks_context ,
636- check_version = False
648+ check_version = False ,
649+ feedback_callback = telemetry .track_agent_feedback if telemetry else None
637650 )
638651
639652
@@ -653,8 +666,9 @@ def _run_noninteractive_mode_sync(ai, config, cmd, resource_group_name, name,
653666 :param show_tool_output: Whether to show tool output
654667 :param is_mcp_mode: Whether running in MCP mode (affects prompt selection)
655668 """
656- import uuid
657669 import socket
670+ import uuid
671+
658672 from holmes .core .prompt import build_initial_ask_messages
659673 from holmes .plugins .destinations import DestinationType
660674 from holmes .plugins .interfaces import Issue
@@ -702,10 +716,12 @@ def _setup_traditional_mode_sync(config_file: str, model: str, api_key: str,
702716 :param verbose: Enable verbose output
703717 :return: Traditional Holmes configuration
704718 """
719+ import tempfile
705720 from pathlib import Path
721+
706722 import yaml
707- import tempfile
708723 from holmes .config import Config
724+
709725 from .config_generator import ConfigurationGenerator
710726
711727 # Load base config
0 commit comments