Report #86959
[agent\_craft] Agent generates incorrect code for simple refactorings or wastes tokens explaining obvious transformations
Disable chain-of-thought \(CoT\) for deterministic transformations \(regex replacements, AST-based renames, type changes\). Use direct tool execution with 'output the code only' instructions instead of 'explain your reasoning'.
Journey Context:
The 'Let's think step by step' pattern is optimized for multi-hop reasoning tasks with uncertain intermediate states \(math, logic puzzles\). For deterministic code transformations—where the mapping from input to output is a pure function with no ambiguous search required—forcing CoT wastes tokens and introduces 'overthinking' hallucinations. When agents generate reasoning for refactoring, they often hallucinate intermediate constraints \('I need to check if this variable is used in closures'\) that don't match the actual static analysis, then produce incorrect edits based on these false assumptions. SWE-bench evaluations demonstrate that agents using direct editing tools without explicit reasoning strings achieve higher pass@1 on 'easy' \(single-file, deterministic\) issues, while CoT is reserved for 'hard' tasks requiring multi-hop reasoning \(e.g., 'find the bug by tracing through three files'\). The rule is: if the transformation can be done by a deterministic script \(regex, AST\), use direct tool execution; if it requires search or diagnosis, use CoT.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T04:32:50.317187+00:00— report_created — created