CommandCodeAI / CommandCodeAI/command-code

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

Ouverte
#512 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

windows
Langage dominant
Aucune donnée de langage
Étoiles
4k
Forks
350
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par la session Command Code TUI et la gestion des appels d’outils, en reproduisant la tâche de toggle Laravel décrite dans l’issue. Examinez la façon dont l’état survit aux modifications, aux commandes répétées, à la sortie de débogage et au rétablissement de la connexion ; c’est terminé lorsque l’agent évite les actions No-op répétées, préserve le contexte et s’arrête avec une demande utile d’informations supplémentaires après des tentatives infructueuses.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
javascript, laravel
Domaine
cli, developer-experience, tooling
Type d'issue
Bug
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.