Report #30565
[cost\_intel] Claude 3.5 Sonnet vs GPT-4o-mini for code generation and refactoring tasks
Use frontier models \(Sonnet, GPT-4o, Pro\) for greenfield code generation >100 lines or cross-file refactoring with architectural changes; use GPT-4o-mini/Haiku only for localized edits \(<30 lines\) with high-signal context \(specific function signature \+ inline comments\), or for syntax-level transformations \(language conversion, lint fixes\) where edit distance is small and validation is automated.
Journey Context:
The common mistake is thinking 'code is code' and using small models for big refactors to save money. Code generation has a compounding error property: a mistake in line 20 causes cascading failures in lines 50-100. Frontier models maintain coherent architecture across long contexts; small models lose thread after ~200 tokens of generation, leading to 'hallucinated APIs' and inconsistent variable naming. However, for small, scoped edits—like 'change this function to use async/await' where the context is the single function body—small models perform at 95%\+ of frontier quality because the search space is constrained. The break-even is around 50 lines of generated code or any task requiring 'planning' \(e.g., 'refactor this monolith into microservices'\). For pure syntactic transformations \(Python 2 to 3, adding type hints\), small models are actually preferred because they overfit less to 'semantic meaning' and just do the pattern replacement.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:41:19.166401+00:00— report_created — created