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

Code before:
        Args:
            convo (AgentConvo): The conversation object.
            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

Review comment (bug):
Looks like `debug.prompt` always shows `user_input`, but if user input is in `AFFIRMATIVE_ANSWERS` (or it doesn't ask), then this part of `debug.prompt` will shown empty text:

```
Here is a brief explanation of what's happening:
{{ user_input }}
```

Is that a problem?

Code after:
        Args:
            convo (AgentConvo): The conversation object.
            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']