From 3d97cbf24bfafdfb8d8c856121696811f80da3be Mon Sep 17 00:00:00 2001 From: Al Sharma <9090916+kunalnano@users.noreply.github.com> Date: Mon, 12 Jan 2026 14:34:42 -0600 Subject: [PATCH] fix: exit agent loop when all features pass Previously, the autonomous agent would continue running indefinitely even after all features passed verification. The agent would enter a verification loop, repeatedly checking 'All features are passing!' without ever exiting. This fix detects the completion message from feature_get_next() and gracefully exits the main loop with a victory banner, preventing unnecessary API calls and resource consumption. Fixes infinite loop when project reaches 100% completion. --- agent.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/agent.py b/agent.py index 50edc46..f1206e2 100644 --- a/agent.py +++ b/agent.py @@ -14,7 +14,7 @@ from pathlib import Path from typing import Optional from zoneinfo import ZoneInfo -from claude_agent_sdk import ClaudeSDKClient +from claude_code_sdk import ClaudeSDKClient # Fix Windows console encoding for Unicode characters (emoji, etc.) # Without this, print() crashes when Claude outputs emoji like ✅ @@ -196,6 +196,14 @@ async def run_autonomous_agent( async with client: status, response = await run_agent_session(client, prompt, project_dir) + # Check for project completion - EXIT when all features pass + if "all features are passing" in response.lower() or "no more work to do" in response.lower(): + print("\n" + "=" * 70) + print(" 🎉 PROJECT COMPLETE - ALL FEATURES PASSING!") + print("=" * 70) + print_progress_summary(project_dir) + break + # Handle status if status == "continue": delay_seconds = AUTO_CONTINUE_DELAY_SECONDS