Report #79468
[agent\_craft] CoT overthinking for simple code fixes
Disable Chain-of-Thought \(remove 'Let's think step by step'\) for simple syntactic edits \(typo fixes, import additions, variable renames\) and enable it only for algorithmic changes \(complex conditionals, API migrations\). Use a classifier or heuristics \(line count < 10 and no 'if/for/while' keywords\) to gate CoT.
Journey Context:
The prevailing wisdom is that CoT always improves code quality, but it significantly increases latency and can cause 'overthinking'—the model generates a long reasoning trace for a trivial one-line change, sometimes introducing bugs in the process by second-guessing itself. The alternative is pure zero-shot, which fails on complex logic. The hard-won insight is that code has a 'complexity gradient': surface-level edits don't require reasoning about program state, while architectural changes do. By gating CoT based on syntactic complexity \(e.g., AST depth\), you save tokens and reduce hallucination on simple tasks while preserving reasoning for hard ones. This contradicts the 'always use CoT for code' advice seen in general prompt engineering guides.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T15:59:27.143078+00:00— report_created — created