From 0f8109ec00bc4b44bc4a9ace566974a823e1f414 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 21 Nov 2025 01:49:07 +0300 Subject: [PATCH] single task --- tools/agent/agent_orchestrator.py | 139 ++++++++++++++---------------- 1 file changed, 67 insertions(+), 72 deletions(-) diff --git a/tools/agent/agent_orchestrator.py b/tools/agent/agent_orchestrator.py index 76714ff..a557f82 100644 --- a/tools/agent/agent_orchestrator.py +++ b/tools/agent/agent_orchestrator.py @@ -1,6 +1,6 @@ """ Main orchestrator for AI agent execution. -Manages the development cycle: read tasks -> execute -> test -> commit -> repeat +Executes a single task per run: read task -> execute -> test -> commit """ import sys import subprocess @@ -33,12 +33,12 @@ class AgentOrchestrator: def run(self) -> int: """ - Main execution loop. + Execute a single task from the task list. Returns: 0 on success, 1 on error """ print(f"šŸš€ Starting AI Agent for component: {self.config.component}") print(f"šŸ“ Project root: {self.config.project_root}") - print(f"šŸŽÆ Max iterations: {self.config.max_iterations}") + print(f"šŸŽÆ Executing one task per run") # Check if another agent is running if self.task_manager.is_agent_running(): @@ -47,76 +47,71 @@ class AgentOrchestrator: return 0 try: - # Main development loop - while True: - state = self.task_manager.load_state() - - # Check iteration limit - if state.iteration_count >= self.config.max_iterations: - print(f"\nā¹ļø Reached maximum iterations ({self.config.max_iterations})") - break - - # Get next task - next_task = self.task_manager.get_next_task() - - if not next_task: - print("\nāœ… All tasks completed!") - self.task_manager.reset_state() - break - - print(f"\n{'='*80}") - print(f"šŸ“‹ Task {state.iteration_count + 1}/{self.config.max_iterations}: {next_task.id}") - print(f"šŸ“ {next_task.title}") - print(f"ā±ļø Estimated: {next_task.estimated_hours}h") - print(f"{'='*80}\n") - - # Start task - self.task_manager.start_task(next_task) - - # Check if task needs global lock (modifies common package) - needs_global_lock = self._needs_global_lock(next_task) - if needs_global_lock: - if not self._acquire_global_lock(): - print("āš ļø Cannot acquire global lock, skipping task") - self.task_manager.mark_task_skipped( - next_task.id, - "Global lock not available" - ) - continue - - try: - # Execute task - success = self._execute_task(next_task) - - if success: - # Task completed successfully - print(f"\nāœ… Task {next_task.id} completed successfully") - self.task_manager.mark_task_completed(next_task.id) - else: - # Task failed - retry_count = self.task_manager.increment_retry() - - if retry_count >= self.config.max_retries: - print(f"\nāŒ Task {next_task.id} failed after {retry_count} retries") - self.task_manager.mark_task_failed( - next_task.id, - f"Failed after {retry_count} retries" - ) - - # Create GitHub issue - self._create_issue_for_failed_task(next_task) - else: - print(f"\nāš ļø Task {next_task.id} failed, will retry ({retry_count}/{self.config.max_retries})") - - finally: - # Release global lock if held - if needs_global_lock: - self.global_lock.release(self.config.component) - - # Small delay between tasks - time.sleep(2) + state = self.task_manager.load_state() - print("\nšŸŽ‰ Agent execution completed") + # Check iteration limit + if state.iteration_count >= self.config.max_iterations: + print(f"\nā¹ļø Reached maximum iterations ({self.config.max_iterations})") + return 0 + + # Get next task + next_task = self.task_manager.get_next_task() + + if not next_task: + print("\nāœ… All tasks completed!") + self.task_manager.reset_state() + return 0 + + print(f"\n{'='*80}") + print(f"šŸ“‹ Task: {next_task.id}") + print(f"šŸ“ {next_task.title}") + print(f"ā±ļø Estimated: {next_task.estimated_hours}h") + print(f"{'='*80}\n") + + # Start task + self.task_manager.start_task(next_task) + + # Check if task needs global lock (modifies common package) + needs_global_lock = self._needs_global_lock(next_task) + if needs_global_lock: + if not self._acquire_global_lock(): + print("āš ļø Cannot acquire global lock, skipping task") + self.task_manager.mark_task_skipped( + next_task.id, + "Global lock not available" + ) + return 0 + + try: + # Execute task + success = self._execute_task(next_task) + + if success: + # Task completed successfully + print(f"\nāœ… Task {next_task.id} completed successfully") + self.task_manager.mark_task_completed(next_task.id) + else: + # Task failed + retry_count = self.task_manager.increment_retry() + + if retry_count >= self.config.max_retries: + print(f"\nāŒ Task {next_task.id} failed after {retry_count} retries") + self.task_manager.mark_task_failed( + next_task.id, + f"Failed after {retry_count} retries" + ) + + # Create GitHub issue + self._create_issue_for_failed_task(next_task) + else: + print(f"\nāš ļø Task {next_task.id} failed, will retry ({retry_count}/{self.config.max_retries})") + + finally: + # Release global lock if held + if needs_global_lock: + self.global_lock.release(self.config.component) + + print("\nšŸŽ‰ Agent execution completed (one task)") return 0 except KeyboardInterrupt: