Skip to content

Conversation

@kunalnano
Copy link
Contributor

@kunalnano kunalnano commented Jan 12, 2026

Problem

The autonomous agent runs indefinitely after all features pass verification.
It enters an infinite "verification loop" - repeatedly calling feature_get_next(),
getting "All features are passing! No more work to do.", and starting a new session.

This wastes API credits and keeps the process running forever until manually killed.

Solution

Detect the completion message in the agent response and break out of the main loop
with a victory banner and final progress summary.

Testing

  • Ran a project to 100% completion (90/90 features)
  • Confirmed agent now exits gracefully instead of looping
  • Session 115+ verification loops no longer occur 😅

Before

Session 115 - Verification Session
✅ All 90 features passing (100%)
... 3 seconds later ...
Session 116 - Verification Session
✅ All 90 features passing (100%)
... forever ...

After

✅ All 90 features passing (100%)
======================================================================
  🎉 PROJECT COMPLETE - ALL FEATURES PASSING!
======================================================================
[exits cleanly]

Summary by CodeRabbit

  • New Features
    • Autonomous agent now detects project completion and displays a completion banner with progress summary before terminating.

✏️ Tip: You can customize this high-level summary in your review settings.

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.
@coderabbitai
Copy link

coderabbitai bot commented Jan 12, 2026

📝 Walkthrough

Walkthrough

The change updates an import path for ClaudeSDKClient and adds project completion detection logic to the autonomous agent loop. When responses contain "all features are passing" or "no more work to do" (case-insensitive), the agent prints a completion summary and terminates.

Changes

Cohort / File(s) Summary
Agent Import & Completion Detection
agent.py
Updated ClaudeSDKClient import path from claude_agent_sdk to claude_code_sdk; added conditional logic to detect project completion phrases in agent responses and break from autonomous loop with completion banner and progress summary

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Poem

🐇 The agent hops through tasks with glee,
But now knows when to stop and see,
"All features pass!" the message rings,
A banner flies with completion's wings! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately reflects the main change: detecting project completion and exiting the agent loop when all features pass, which directly addresses the infinite loop problem described in the PR objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 07c2010 and 3d97cbf.

📒 Files selected for processing (1)
  • agent.py
🧰 Additional context used
📓 Path-based instructions (3)
*.py

📄 CodeRabbit inference engine (CLAUDE.md)

Python backend should use the ClaudeSDKClient configuration in client.py with security hooks and MCP servers

Files:

  • agent.py
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

Use SQLite with SQLAlchemy ORM for database access and feature management

Files:

  • agent.py
agent.py

📄 CodeRabbit inference engine (CLAUDE.md)

Agent sessions should auto-continue with a 3-second delay between sessions

Files:

  • agent.py
🧠 Learnings (2)
📚 Learning: 2026-01-10T08:23:04.012Z
Learnt from: CR
Repo: leonvanzyl/autocoder PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T08:23:04.012Z
Learning: Applies to *.py : Python backend should use the ClaudeSDKClient configuration in client.py with security hooks and MCP servers

Applied to files:

  • agent.py
📚 Learning: 2026-01-10T08:23:04.012Z
Learnt from: CR
Repo: leonvanzyl/autocoder PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T08:23:04.012Z
Learning: Applies to agent.py : Agent sessions should auto-continue with a 3-second delay between sessions

Applied to files:

  • agent.py
🧬 Code graph analysis (1)
agent.py (1)
progress.py (1)
  • print_progress_summary (211-223)
🔇 Additional comments (2)
agent.py (2)

199-205: LGTM! Correctly addresses the infinite loop issue.

The completion detection logic properly breaks out of the autonomous loop when the agent signals all features are passing. The case-insensitive check and the victory banner with progress summary provide a clean termination path.

One consideration: this check runs before the status handling (line 208+), so even if status == "error", the agent exits if the response contains completion phrases. This is likely the correct behavior since a completion message indicates overall success.


17-17: Fix incorrect import path in agent.py line 17.

The import uses claude_code_sdk but the manifest declares claude-agent-sdk. All other files in the codebase correctly import from claude_agent_sdk (see client.py and server/services/). This will cause an ImportError at runtime.

Change line 17 to:

from claude_agent_sdk import ClaudeSDKClient
⛔ Skipped due to learnings
Learnt from: CR
Repo: leonvanzyl/autocoder PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T08:23:04.012Z
Learning: Applies to agent.py : Agent sessions should auto-continue with a 3-second delay between sessions
Learnt from: CR
Repo: leonvanzyl/autocoder PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T08:23:04.012Z
Learning: Applies to *.py : Python backend should use the ClaudeSDKClient configuration in client.py with security hooks and MCP servers

Comment @coderabbitai help to get the list of available commands and usage tips.

@heyWayneK
Copy link

Great. Thanks this is a real problem. I will test

pRizz added a commit to pRizz/autocoder that referenced this pull request Jan 21, 2026
…ures

- Verified Kanban board renders 144 features without lag
- Tested scrolling performance (0.1ms programmatic scroll)
- All feature cards display correctly with proper data
- Screenshots captured for verification

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
pRizz added a commit to pRizz/autocoder that referenced this pull request Jan 21, 2026
- Verified ? key opens keyboard shortcuts modal
- Verified 8 shortcuts listed (?, A, D, G, K, N, ,, Esc)
- Verified Escape key closes modal
- Added verification screenshots

Feature was already implemented, this commit documents verification.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@leonvanzyl
Copy link
Owner

Security Review Findings ⚠️

I've conducted a thorough security analysis of this PR using multiple review passes. Here are the findings:

Critical Issue: Undocumented Import Change

The diff contains a change not mentioned in the PR description:

-from claude_agent_sdk import ClaudeSDKClient
+from claude_code_sdk import ClaudeSDKClient

Concerns:

  1. claude-code-sdk is deprecated (last updated Sep 2025)
  2. claude-agent-sdk is the active, maintained package (last updated Jan 2026)
  3. This change is not documented in the PR title, description, or commit message
  4. This would cause an ImportError since requirements.txt specifies claude-agent-sdk>=0.1.0
  5. The change is incomplete - only agent.py is modified, but 4 other files still import from claude_agent_sdk

Security Scan: Clean ✅

  • No malicious code detected
  • No Unicode homoglyphs or hidden characters
  • No supply chain attack (both packages are official Anthropic packages)
  • The emoji is legitimate UTF-8

Completion Detection Logic: Acceptable ✅

The completion detection code itself is fine:

  • Type-safe (response is always a string)
  • print_progress_summary has no security issues
  • The break placement is correct (no cleanup skipped)

Requested Changes

Before this PR can be merged, please:

  1. Explain why the import was changed from claude_agent_sdk to claude_code_sdk
  2. Remove the import change (keep using claude_agent_sdk) - or provide justification for the regression to deprecated software
  3. If the import change was accidental, please revert it

The completion detection fix addresses a real issue, but the undocumented import change prevents merging as-is.

@leonvanzyl leonvanzyl merged commit a71406c into leonvanzyl:master Jan 22, 2026
1 check passed
@leonvanzyl
Copy link
Owner

I have merged the changes, but will add back the correct claude agent SDK,

leonvanzyl added a commit that referenced this pull request Jan 22, 2026
Changes:
- Revert incorrect import from claude_code_sdk to claude_agent_sdk in agent.py
  (PR #50 introduced an undocumented change to a deprecated package)
- Clear activeAgents and recentActivity in useWebSocket when agent stops
  to prevent stale UI state

The claude_code_sdk package is deprecated (last updated Sep 2025) while
claude_agent_sdk is the active, maintained package. The import change in
PR #50 was undocumented and would have caused ImportError since only
claude-agent-sdk is specified in requirements.txt.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants