CommandCodeAI / CommandCodeAI/command-code

Bug Report: Agent Thrashing / Infinite Loop on Simple Debugging Task

Offen
#512 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

windows
Vorherrschende Sprache
Keine Sprachdaten
Sterne
4k
Forks
350
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Summary

On a simple, well-scoped debugging task (fix a JavaScript fetch error on a toggle button), the agent entered an infinite loop repeatedly making contradictory edits, undoing its own changes, and running useless commands — without ever resolving the issue. The session ran for an extended period with zero net progress.

Environment:
OS: Windows (native) / WSL Ubuntu
Command Code version: v0.26.2
Model: DeepSeek V4 Pro
Project: Laravel (Blade + vanilla JS fetch)
Tool: Command Code TUI

Task Given

"I'm still getting error toggling address status, even though the toggle works"

This is a straightforward AJAX/JSON mismatch debug expected resolution time under 2 minutes. The fix requires reading the JS fetch block and the controller method, identifying the mismatch, and applying a single change.

Impact:
Developer time wasted on a task that should take under 2 minutes
Multiple unnecessary file edits creating noisy git history
No resolution — bug remained unfixed after the entire session
Loss of confidence in the tool for production codebase work

Expected Behavior

Expected Behavior:

Read all relevant files before making any edit; in this case the JS fetch block and the controller method should have been read together before the first fix attempt
Maintain state across tool calls; if an edit was just made and reverted, the agent should recognize it's in a loop and stop, not continue the same cycle
Use debug output before discarding it; console.log statements should be added, the developer prompted to check the browser console, and the output acted upon before those statements are removed
Circuit breaker on repeated failed attempts; after 3 attempts at the same fix with no resolution, the agent should stop, summarize what it has tried, and ask the developer for additional context (e.g. browser console output, network tab response) rather than continuing to thrash
Cache clear is a one-time action — running php artisan view:clear more than once per session on the same issue should be flagged as a no-op and skipped

Actual Behavior

Observed Behavior

Repeated useless commands

  • php artisan view:clear && php artisan cache:clear was executed at least 6 times across the session. This command clears compiled view cache — it has no effect on a JavaScript/controller JSON response mismatch. Running it repeatedly after the first time is pure cargo-cult debugging with zero diagnostic value.

  • Contradictory edits with no logical progression

  • The controller's JSON response was changed back and forth repeatedly with no reasoning:

Iteration 1: return response()->json(['success' => true, 'message' => 'Status updated']);
Iteration 2: return response()->json(['success' => true]);
Iteration 3: return response()->json(['success' => true], 200);
Iteration 4: return response()->json(['success' => true]);
Iteration 5: return response()->json(['success' => true, 'new_status' => ...]);
Iteration 6: return response()->json(['success' => true, 'is_active' => $address->is_active]);
Iteration 7: return response()->json(['success' => true]);

The agent cycled through variations and back again with no forward progress — the final state is identical to iteration 2.

Debug instrumentation added then immediately removed without reading output

Console.log statements were added to the JavaScript:

javascriptconsole.log('Toggling address:', addressId);
console.log('URL:', url);
console.log('CSRF Token:', token);

These were removed in the very next edit without any indication the output was read or acted upon. Adding debug logging and then discarding it without using the information is worse than not adding it at all, it wastes tokens and makes the session history harder to follow.

Agent undoing its own changes

The fetch body was changed from:

javascriptbody: JSON.stringify({ _token: token })

to:

javascriptbody: JSON.stringify({})

And then back to:

javascriptbody: JSON.stringify({ _token: token })

The agent literally reversed its own edit within the same session, indicating complete loss of state between tool calls.

Connection error mid-session

⚠ Error: Connection error.
Type "continue" to try again.
Trace ID: 0b6ba5836ae889bdadab439845195504

A connection drop mid-session with no graceful recovery or context resumption. The agent restarted from scratch rather than resuming with awareness of what had already been tried.

Root Cause of the Loop (the actual bug the agent failed to find)

The real issue was a straightforward JSON response/fetch mismatch — a 2-minute fix requiring:
Read the JS fetch block fully
Read the controller method fully
Identify the specific mismatch
Apply one targeted fix

The agent never achieved this because it was not reading both files together holistically before each edit attempt — it was making isolated, incremental changes without maintaining full context of the problem across tool calls.

Steps to reproduce the issue
  1. Open an existing Laravel project with a toggle button that makes a JavaScript fetch() POST request to a controller endpoint
  2. Start a new Command Code session with DeepSeek V4 Pro
  3. Report the error: "I'm getting a javascript alert error while toggling address status, even though the toggle works"
  4. Observe the agent begin editing the controller's JSON response without first reading the JavaScript fetch block and controller method together
  5. Continue the session — observe the agent run php artisan view:clear && php artisan cache:clear repeatedly (6+ times) with no diagnostic value
  6. Observe the agent add console.log debug statements to the JavaScript, then remove them in the very next edit without reading or acting on the output
  7. Observe the controller response toggled back and forth across 7+ iterations with no forward progress, ending in the same state it started
  8. Observe the fetch body changed from JSON.stringify({ _token: token }) → JSON.stringify({}) → back to JSON.stringify({ _token: token }) — the agent reversing its own edit within the same session.

Note that the bug remains unresolved after the entire session 🤦‍♂️🤦‍♂️

Command Code Version

Unknown

Operating System

Windows

Terminal/IDE

Unknown

Shell

bash

Additional context

No response

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie mit der Command Code TUI-Sitzung und der Verarbeitung von Tool-Aufrufen und reproduzieren Sie die in der issue beschriebene Laravel-Toggle-Aufgabe. Untersuchen Sie, wie der Zustand Änderungen, wiederholte Befehle, die Debug-Ausgabe und die Wiederherstellung der Verbindung übersteht; fertig ist die Aufgabe, wenn der Agent wiederholte No-op-Aktionen vermeidet, den Kontext bewahrt und nach fehlgeschlagenen Versuchen mit einer nützlichen Bitte um weitere Informationen anhält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, laravel
Bereich
cli, developer-experience, tooling
Issue-Typ
Bug
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.