Repository: Pythagora-io/gpt-pilot
File: pilot/helpers/Debugger.py (Python)

Code before:
            command (dict, optional): The command to debug. Default is None.
            user_input (str, optional): User input for debugging. Default is None.
                Should provide `command` or `user_input`.
            issue_description (str, optional): Description of the issue to debug. Default is None.
            ask_before_debug (bool, optional): True if we have to ask user for permission to start debugging.

        Returns:
            bool: True if debugging was successful, False otherwise.
        """
        logger.info('Debugging %s', command)
        self.recursion_layer += 1
        if self.recursion_layer > MAX_RECUSION_LAYER:
            self.recursion_layer = 0
            raise TooDeepRecursionError()

        function_uuid = str(uuid.uuid4())
        convo.save_branch(function_uuid)
        success = False

        for i in range(MAX_COMMAND_DEBUG_TRIES):
            if success:
                break

            if ask_before_debug or i > 0:
                answer = ask_user(self.agent.project, 'Can I start debugging this issue?', require_some_input=False)
                if answer in NEGATIVE_ANSWERS:
                    return True
                if answer and answer not in AFFIRMATIVE_ANSWERS:
                    user_input = answer

            llm_response = convo.send_message('dev_ops/debug.prompt',
                {
                    'command': command['command'] if command is not None else None,
                    'user_input': user_input,
                    'issue_description': issue_description,
                    'os': platform.system(),
                    'context': convo.to_context_prompt()
                },
                DEBUG_STEPS_BREAKDOWN)

            completed_steps = []

            try:
                while True:
                    logger.info('Thoughts: ' + llm_response['thoughts'])
                    logger.info('Reasoning: ' + llm_response['reasoning'])
                    steps = completed_steps + llm_response['steps']

                    # TODO refactor to nicely get the developer agent
                    result = self.agent.project.developer.execute_task(
                        convo,

Review comment (bug):
Maybe we should check with `answer.lower()` here (and in the `if` below). Also, a suggestion, how about we use the user prompt like this (ie. list examples how it can be answered):

> Can I start debugging this issue [y / n / comment]? 

Code after:
            command (dict, optional): The command to debug. Default is None.
            user_input (str, optional): User input for debugging. Default is None.
                Should provide `command` or `user_input`.
            issue_description (str, optional): Description of the issue to debug. Default is None.
            ask_before_debug (bool, optional): True if we have to ask user for permission to start debugging.

        Returns:
            bool: True if debugging was successful, False otherwise.
        """
        logger.info('Debugging %s', command)
        self.recursion_layer += 1
        if self.recursion_layer > MAX_RECUSION_LAYER:
            self.recursion_layer = 0
            raise TooDeepRecursionError()

        function_uuid = str(uuid.uuid4())
        convo.save_branch(function_uuid)
        success = False

        for i in range(MAX_COMMAND_DEBUG_TRIES):
            if success:
                break

            if ask_before_debug or i > 0:
                print('yes/no', type='button')
                answer = ask_user(self.agent.project, 'Can I start debugging this issue?', require_some_input=False)
                if answer.lower() in NEGATIVE_ANSWERS:
                    return True
                if answer and answer.lower() not in AFFIRMATIVE_ANSWERS:
                    user_input = answer

            llm_response = convo.send_message('dev_ops/debug.prompt',
                {
                    'command': command['command'] if command is not None else None,
                    'user_input': user_input,
                    'issue_description': issue_description,
                    'os': platform.system(),
                    'context': convo.to_context_prompt()
                },
                DEBUG_STEPS_BREAKDOWN)

            completed_steps = []

            try:
                while True:
                    logger.info('Thoughts: ' + llm_response['thoughts'])
                    logger.info('Reasoning: ' + llm_response['reasoning'])
                    steps = completed_steps + llm_response['steps']

                    # TODO refactor to nicely get the developer agent
                    result = self.agent.project.developer.execute_task(