def parse_llm_response(self, response: str, mode: str = 'search') -> Dict[str, Union[str, List[int], AnalysisResult]]:
        """
        Parse LLM response based on mode

        Args:
            response (str): The LLM's response text
            mode (str): 'search' for web search, 'research' for strategic analysis

        Returns:
            Dict containing parsed response
        """
        logger.info(f"Starting to parse LLM response in {mode} mode")

        if mode == 'research':
            return self._parse_research_response(response)

        # Original search mode parsing
        result = {
            'decision': None,
            'reasoning': None,
            'selected_results': [],
            'response': None
        }

        parsing_strategies = [
            self._parse_structured_response,
            self._parse_json_response,
            self._parse_unstructured_response,
            self._parse_implicit_response
        ]

        for strategy in parsing_strategies:
            try:
                parsed_result = strategy(response)
                if self._is_valid_result(parsed_result):
                    result.update(parsed_result)
                    logger.info(f"Successfully parsed using strategy: {strategy.__name__}")
                    break
            except Exception as e:
                logger.warning(f"Error in parsing strategy {strategy.__name__}: {str(e)}")

        if not self._is_valid_result(result):
            logger.warning("All parsing strategies failed. Using fallback parsing.")
            result = self._fallback_parsing(response)

        result = self._post_process_result(result)

        logger.info("Finished parsing LLM response")
        return result

        Parse LLM response based on mode

        Args:
            response (str): The LLM's response text
            mode (str): 'search' for web search, 'research' for strategic analysis

        Returns:
            Dict containing parsed response
        
llm_response_parser.py