Report #26827
[agent\_craft] Few-shot examples override target codebase style causing generated code to mismatch surrounding files
For style-sensitive refactoring or code adaptation tasks, prefer zero-shot with an explicit, detailed style specification \(e.g., 'use 2-space indentation, prefer list comprehensions over map, follow Google Python Style Guide'\) over few-shot examples from other codebases. If using few-shot, retrieve examples exclusively from the target repository to ensure style consistency.
Journey Context:
The common intuition is that more examples \(few-shot\) always improve performance. However, for code refactoring—where the goal is to adapt code to match a specific existing codebase—few-shot examples from external sources \(e.g., Stack Overflow snippets\) introduce 'style contamination'. The Codex paper noted that few-shot helps with API usage patterns but can hurt style consistency. Zero-shot with explicit constraints forces the model to rely on its pre-trained knowledge of the specific style guide provided, which is more robust than imitating potentially mismatched examples. The tradeoff is that zero-shot requires more prompt engineering to specify the style explicitly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T23:25:50.608685+00:00— report_created — created