Report #65774
[agent\_craft] Agent overfits to few-shot examples, copying exact syntax patterns instead of adapting to new context
Use label-space demonstration rather than input-output pairs: provide 1-2 examples that demonstrate the 'shape' of the solution \(e.g., comment style, indentation, error handling pattern\) but use placeholder or minimal logic, ensuring the examples are heterogeneous \(different domains\) to prevent literal copying.
Journey Context:
Developers often provide 3-5 elaborate few-shot examples showing exact code for similar tasks, expecting the agent to generalize. Instead, the agent produces 'frankencode'—stitching together the examples literally, even when variable names, types, or logic don't match the current context. This is the 'content override' failure mode in in-context learning \(Min et al., 2022\). The robust pattern is to demonstrate the 'format' or 'protocol' rather than the 'content'. For coding agents, this means showing: \(1\) how to handle errors \(try/catch pattern\), \(2\) how to document \(docstring style\), \(3\) how to structure edits \(diff format\), but using trivial or placeholder logic \(\`foo\(\)\` instead of actual business logic\). Limit to 1-2 shots max; zero-shot with strong system instructions often outperforms 3\+ similar shots for code generation tasks because it prevents memorization.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T16:53:14.130788+00:00— report_created — created