diff --git a/pilot/const/code_execution.py b/pilot/const/code_execution.py index 5f74281..f4f3f4e 100644 --- a/pilot/const/code_execution.py +++ b/pilot/const/code_execution.py @@ -1,3 +1,4 @@ MAX_COMMAND_DEBUG_TRIES = 3 MIN_COMMAND_RUN_TIME = 2000 MAX_COMMAND_RUN_TIME = 30000 +MAX_COMMAND_OUTPUT_LENGTH = 2000 diff --git a/pilot/helpers/AgentConvo.py b/pilot/helpers/AgentConvo.py index 471e90a..b8c5081 100644 --- a/pilot/helpers/AgentConvo.py +++ b/pilot/helpers/AgentConvo.py @@ -43,6 +43,7 @@ class AgentConvo: if self.agent.project.skip_until_dev_step and str(development_step.id) == self.agent.project.skip_until_dev_step: self.agent.project.skip_steps = False delete_all_subsequent_steps(self.agent.project) + if 'delete_unrelated_steps' in self.agent.project.args and self.agent.project.args['delete_unrelated_steps']: self.agent.project.delete_all_steps_except_current_branch() else: diff --git a/pilot/helpers/agents/Developer.py b/pilot/helpers/agents/Developer.py index 5a23d3d..a5cace6 100644 --- a/pilot/helpers/agents/Developer.py +++ b/pilot/helpers/agents/Developer.py @@ -141,7 +141,7 @@ class Developer(Agent): iteration_convo.remove_last_x_messages(2) self.execute_task(iteration_convo, task_steps, continue_development=False) - + def set_up_environment(self): self.project.current_step = 'environment_setup' self.convo_os_specific_tech = AgentConvo(self) diff --git a/pilot/helpers/cli.py b/pilot/helpers/cli.py index c87f80c..c34d8a1 100644 --- a/pilot/helpers/cli.py +++ b/pilot/helpers/cli.py @@ -11,7 +11,7 @@ from database.database import get_command_run_from_hash_id, save_command_run from const.function_calls import DEBUG_STEPS_BREAKDOWN from utils.questionary import styled_text -from const.code_execution import MAX_COMMAND_DEBUG_TRIES, MIN_COMMAND_RUN_TIME, MAX_COMMAND_RUN_TIME +from const.code_execution import MAX_COMMAND_DEBUG_TRIES, MIN_COMMAND_RUN_TIME, MAX_COMMAND_RUN_TIME, MAX_COMMAND_OUTPUT_LENGTH interrupted = False @@ -71,6 +71,7 @@ def execute_command(project, command, timeout=None, force=False): pid_container = [None] process = run_command(command, project.root_path, q, q_stderr, pid_container) output = '' + stderr_output = '' start_time = time.time() interrupted = False @@ -105,6 +106,17 @@ def execute_command(project, command, timeout=None, force=False): if line: output += line print(colored('CLI OUTPUT:', 'green') + line, end='') + + # Read stderr + try: + stderr_line = q_stderr.get_nowait() + except queue.Empty: + stderr_line = None + + if stderr_line: + stderr_output += stderr_line + print(colored('CLI ERROR:', 'red') + stderr_line, end='') # Print with different color for distinction + except (KeyboardInterrupt, TimeoutError) as e: interrupted = True if isinstance(e, KeyboardInterrupt): @@ -114,15 +126,15 @@ def execute_command(project, command, timeout=None, force=False): os.killpg(pid_container[0], signal.SIGKILL) # Kill the process group - stderr_output = '' - while not q_stderr.empty(): - stderr_output += q_stderr.get_nowait() + # stderr_output = '' + # while not q_stderr.empty(): + # stderr_output += q_stderr.get_nowait() if return_value is None: return_value = '' if stderr_output != '': - return_value = 'stderr:\n```\n' + stderr_output[-2000:] + '\n```\n' - return_value += 'stdout:\n```\n' + output[-2000:] + '\n```' + return_value = 'stderr:\n```\n' + stderr_output[-MAX_COMMAND_OUTPUT_LENGTH:] + '\n```\n' + return_value += 'stdout:\n```\n' + output[-MAX_COMMAND_OUTPUT_LENGTH:] + '\n```' command_run = save_command_run(project, command, return_value)