Report #39568
[agent\_craft] Agent produces code that overfits to variable names and logic patterns from few-shot examples instead of user's specific requirements
Use zero-shot with strong typing hints and docstrings for standard coding tasks. Reserve few-shot only for: 1\) Highly idiomatic patterns \(e.g., specific error handling in a framework\), 2\) Teaching a novel DSL or API that isn't in training data, 3\) Correcting a persistent systematic error the agent makes. When using few-shot, scrub examples of specific variable names \(use 'foo', 'bar' or generic types\) to prevent semantic contamination.
Journey Context:
The intuition is that 'more examples = better performance,' but for code generation, in-context examples often act as strong priors that override the user's natural language instructions. Studies show that models often ignore the label space and input distribution in favor of the example's surface form. In coding, this manifests as the agent copying the exact regex pattern from the example even when the user asked for something different. Zero-shot with precise type annotations \(Python's \`typing\` module, TypeScript interfaces\) provides clearer constraints without the baggage of example logic. This pattern was observed in production coding agents which moved from implicit few-shot to implicit zero-shot with context retrieval.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T20:53:28.786019+00:00— report_created — created