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

Code before:
                            break
                    else:
                        raise e
                except TooDeepRecursionError as e:
                    if is_root_task:
                        result = self.dev_help_needed(step)
                        break
                    else:
                        raise e

        result = {"success": True}  # if all steps are finished, the task has been successfully implemented
        convo.load_branch(function_uuid)
        return self.task_postprocessing(convo, development_task, continue_development, result, function_uuid)

    def continue_development(self, iteration_convo, last_branch_name, continue_description='', development_task=None):
        while True:
            logger.info('Continue development, last_branch_name: %s', last_branch_name)
            if last_branch_name in iteration_convo.branches.keys():  # if user_feedback is not None we create new convo
                iteration_convo.load_branch(last_branch_name)
            user_description = ('Here is a description of what should be working: \n\n' + color_cyan_bold(
                continue_description) + '\n') \
                if continue_description != '' else ''
            user_description = 'Can you check if the app works please? ' + user_description

            if self.run_command:
                if self.project.ipc_client_instance is None or self.project.ipc_client_instance.client is None:
                    user_description += color_yellow_bold(
                        '\n\nIf you want to run the app, just type "r" and press ENTER and that will run `' + self.run_command + '`')
                else:
                    print(self.run_command, type='run_command')

            # continue_description = ''
            # TODO: Wait for a specific string in the output or timeout?
            response = self.project.ask_for_human_intervention(
                user_description,
                cbs={'r': lambda convo: run_command_until_success(convo, self.run_command,
                                                                  # name the process so the LLM can kill it
                                                                  command_id='app',
                                                                  # If the app doesn't crash in the first 1st second
                                                                  # assume it's good and leave it running.
                                                                  # If timeout is None the conversation can't continue
                                                                  timeout=None,
                                                                  force=True,
                                                                  return_cli_response=True, is_root_task=True)},
                convo=iteration_convo,
                is_root_task=True)

            logger.info('response: %s', response)
            user_feedback = response['user_input'] if 'user_input' in response else None
            if user_feedback == 'continue':
                return {"success": True, "user_input": user_feedback}

Review comment (suggestion):
logic is same as before just instead of checking
`if not self.project.check_ipc():`
I swapped it around so that we are checking 
`if self.project.check_ipc():`

Code after:
                            break
                    else:
                        raise e
                except TooDeepRecursionError as e:
                    if is_root_task:
                        result = self.dev_help_needed(step)
                        break
                    else:
                        raise e

        result = {"success": True}  # if all steps are finished, the task has been successfully implemented
        convo.load_branch(function_uuid)
        return self.task_postprocessing(convo, development_task, continue_development, result, function_uuid)

    def continue_development(self, iteration_convo, last_branch_name, continue_description='', development_task=None):
        while True:
            logger.info('Continue development, last_branch_name: %s', last_branch_name)
            if last_branch_name in iteration_convo.branches.keys():  # if user_feedback is not None we create new convo
                iteration_convo.load_branch(last_branch_name)
            user_description = ('Here is a description of what should be working: \n\n' + color_cyan_bold(
                continue_description) + '\n') \
                if continue_description != '' else ''
            user_description = 'Can you check if the app works please? ' + user_description

            if self.run_command:
                if self.project.check_ipc():
                    print(self.run_command, type='run_command')
                else:
                    user_description += color_yellow_bold(
                        '\n\nIf you want to run the app, just type "r" and press ENTER and that will run `' + self.run_command + '`')

            # continue_description = ''
            # TODO: Wait for a specific string in the output or timeout?
            response = self.project.ask_for_human_intervention(
                user_description,
                cbs={'r': lambda convo: run_command_until_success(convo, self.run_command,
                                                                  # name the process so the LLM can kill it
                                                                  command_id='app',
                                                                  # If the app doesn't crash in the first 1st second
                                                                  # assume it's good and leave it running.
                                                                  # If timeout is None the conversation can't continue
                                                                  timeout=None,
                                                                  force=True,
                                                                  return_cli_response=True, is_root_task=True)},
                convo=iteration_convo,
                is_root_task=True)

            logger.info('response: %s', response)
            user_feedback = response['user_input'] if 'user_input' in response else None
            if user_feedback == 'continue':
                return {"success": True, "user_input": user_feedback}