From cc017be01a006ef0bcdbf3014a3fd2729ef793c4 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 21 Nov 2025 02:05:04 +0300 Subject: [PATCH] retries --- tools/agent/agent_orchestrator.py | 58 +++++++++++++++++++------------ tools/agent/config.py | 2 +- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/tools/agent/agent_orchestrator.py b/tools/agent/agent_orchestrator.py index a557f82..571cf8d 100644 --- a/tools/agent/agent_orchestrator.py +++ b/tools/agent/agent_orchestrator.py @@ -68,8 +68,9 @@ class AgentOrchestrator: print(f"⏱️ Estimated: {next_task.estimated_hours}h") print(f"{'='*80}\n") - # Start task - self.task_manager.start_task(next_task) + # Start task (only if not already in progress) + if next_task.status != "in_progress": + 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) @@ -83,28 +84,41 @@ class AgentOrchestrator: 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() + # Retry loop: keep trying the same task until success or max retries + while True: + # Get current retry count + current_state = self.task_manager.load_state() + retry_count = current_state.retry_count - 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) + if retry_count > 0: + print(f"\n🔄 Retry attempt {retry_count}/{self.config.max_retries} for task {next_task.id}") + + # 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) + break else: - print(f"\n⚠️ Task {next_task.id} failed, will retry ({retry_count}/{self.config.max_retries})") + # Task failed, increment retry count + 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) + break + else: + print(f"\n⚠️ Task {next_task.id} failed, retrying ({retry_count}/{self.config.max_retries})") + print("Waiting before retry...") + time.sleep(5) # Small delay before retry finally: # Release global lock if held diff --git a/tools/agent/config.py b/tools/agent/config.py index 0898c5b..cb355c6 100644 --- a/tools/agent/config.py +++ b/tools/agent/config.py @@ -17,7 +17,7 @@ class AgentConfig: # Agent limits max_iterations: int = 10 - max_retries: int = 3 + max_retries: int = 5 timeout_hours: int = 6 # Cursor CLI settings