Report #74939
[agent\_craft] Agent replicating deprecated syntax or buggy patterns from few-shot examples, even when asked to use modern idioms
Use 'signature-only' few-shot examples \(function signatures \+ docstrings without implementation\) for API migration tasks; reserve full-implementation few-shots for algorithmic patterns only. Prefer zero-shot with strong system instructions for syntax updates.
Journey Context:
Few-shot prompting is standard for code agents, but including full code examples creates 'syntactic anchoring' where the model copies outdated patterns \(e.g., using deprecated React class components when migrating to hooks, or old Python % formatting instead of f-strings\). This is particularly dangerous in refactoring tasks where the goal is to modernize code—the few-shots inadvertently preserve legacy patterns. The fix uses 'signature-only' examples that provide the interface contract \(types, names, docs\) but force the model to generate fresh implementations aligned with current best practices. This trades off 'pattern demonstration' for 'pattern freedom', which is correct when the target language version differs from the example code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T08:23:09.674013+00:00— report_created — created