CommandCodeAI / CommandCodeAI/command-code
Bug Report: Agent Thrashing / Infinite Loop on Simple Debugging Task
还没有人认领这个 Issue。
- 主要语言
- 没有语言数据
- 星标
- 4k
- 派生
- 350
- PR 合并指标
- 30 天内没有已合并 PR
描述
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
- Open an existing Laravel project with a toggle button that makes a JavaScript fetch() POST request to a controller endpoint
- Start a new Command Code session with DeepSeek V4 Pro
- Report the error: "I'm getting a javascript alert error while toggling address status, even though the toggle works"
- Observe the agent begin editing the controller's JSON response without first reading the JavaScript fetch block and controller method together
- Continue the session — observe the agent run php artisan view:clear && php artisan cache:clear repeatedly (6+ times) with no diagnostic value
- 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
- Observe the controller response toggled back and forth across 7+ iterations with no forward progress, ending in the same state it started
- 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
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Command Code TUI 会话和工具调用处理开始,复现 issue 中描述的 Laravel toggle 任务。检查状态如何在编辑、重复命令、调试输出和连接恢复之后继续保留;完成的标准是 agent 避免重复的 No-op 操作,保留上下文,并在尝试失败后停止,同时提出有用的更多信息请求。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, laravel
- 领域
- cli, developer-experience, tooling
- Issue 类型
- 缺陷
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100