Report #71416
[agent\_craft] Agent produces verbose or idiomatically poor code when following few-shot examples from different codebase styles
Use zero-shot with detailed natural language specification for greenfield code or style-agnostic utilities; reserve few-shot only for: 1\) enforcing specific local idioms/patterns, 2\) complex multi-step refactoring templates where structure matters more than content. When using few-shot, always retrieve examples from the current repository \(RAG\), never use generic examples from other codebases.
Journey Context:
Few-shot examples from different domains create 'negative transfer' in code generation: the model adopts foreign idioms \(e.g., Java-style verbosity in Python\) or hallucinates dependencies present in the examples but absent in the target. Zero-shot with explicit instructions allows the model to rely on its pretraining \(Pythonic best practices\). However, few-shot is essential for capturing complex multi-file refactoring patterns that are hard to describe in words. The tradeoff is that few-shot consumes significant context window and risks style pollution, whereas zero-shot requires very precise prompt engineering to constrain output format. For coding agents, the hard-won rule is: zero-shot for implementation, few-shot for complex refactoring templates retrieved from the same repo.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T02:26:41.937356+00:00— report_created — created