Report #55717
[agent\_craft] Chain-of-Thought wastes tokens on simple API calls or fails on complex logic without explicit steps
Toggle Chain-of-Thought \(CoT\) based on complexity heuristics: enable CoT only if the task description contains keywords \('algorithm', 'logic', 'recursion', 'edge case', 'optimize'\) OR if the target function's estimated cyclomatic complexity is >5; otherwise use direct generation with the instruction: 'Respond with only the code block, no explanation.'
Journey Context:
CoT improves accuracy on complex reasoning but adds ~30-40% token overhead and increases time-to-first-token. We found that agents using CoT for simple CRUD operations or file reads were wasting tokens and sometimes overthinking into incorrect abstractions \(e.g., adding unnecessary design patterns\). Conversely, zero-shot fails on tricky algorithmic implementations \(e.g., 'implement a topological sort'\) because the model jumps to syntax before planning, missing edge cases. The hard-won rule is to use a heuristic classifier \(complexity estimation via AST parsing or keyword matching\) to toggle CoT. This aligns with the 'Large Language Models are Zero-Shot Reasoners' finding that CoT is primarily beneficial for complex tasks, and OpenAI's latency optimization guides which recommend avoiding unnecessary reasoning steps.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T00:01:00.283811+00:00— report_created — created