CommandCodeAI / CommandCodeAI/command-code

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

Aberta
#512 3 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

windows
Linguagem predominante
Sem dados de linguagem
Estrelas
4k
Forks
350
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece com a sessão do Command Code TUI e o tratamento de chamadas de ferramentas, reproduzindo a tarefa de toggle do Laravel descrita na issue. Inspecione como o estado sobrevive a edições, comandos repetidos, saída de depuração e recuperação da conexão; está concluído quando o agente evita ações No-op repetidas, preserva o contexto e para com uma solicitação útil de mais informações após tentativas malsucedidas.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
javascript, laravel
Domínio
cli, developer-experience, tooling
Tipo de issue
Bug
Dificuldade
5/5
Tempo estimado
Mais de uma semana
Status de atividade
Pouca atividade
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.