Report #15181
[agent\_craft] Explicit step-by-step reasoning increases token cost and introduces syntax errors in simple code generation tasks
Reserve explicit chain-of-thought \(CoT\) for debugging, complex algorithmic planning, or multi-step refactoring; use zero-shot direct generation for single-function implementation
Journey Context:
Following the 'Let's think step by step' paper, many agent frameworks applied CoT to all coding tasks. We observed that for straightforward implementations \(e.g., 'write a function to reverse a string'\), CoT caused the model to describe the logic in English first, then attempt to generate code. This often led to 'descriptive drift' where the generated code didn't match the description, or the model would hallucinate syntax errors while trying to explain complex logic. For simple tasks, zero-shot direct generation has higher pass@1 rates. However, for debugging \('why is this function slow?'\) or planning \('design a system with three components'\), CoT is essential. The heuristic we use is: if the task requires 'why' or 'how to structure', use CoT; if it's 'what to write', go direct. This saves ~30-50% of tokens on simple generation tasks.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:21:36.684080+00:00— report_created — created