Report #4981
[agent\_craft] Code agents produce incorrect syntax or deprecated patterns when given few-shot examples from different language versions
Use zero-shot prompting with explicit 'Style: Modern Python 3.11\+' constraints rather than few-shot examples when the target language version or framework version differs from the example source; if few-shot is necessary, verify the examples match the exact version of all dependencies in the target environment.
Journey Context:
Few-shot prompting is effective for style consistency but dangerous for code because examples embed implicit version assumptions. An example using Python 3.8 syntax \(walrus operator absence\) or pandas 1.x methods breaks in a 3.11/pandas 2.0 environment. Zero-shot with explicit version constraints in the system prompt yields higher correctness than mismatched few-shot. Alternatives like dynamic example retrieval \(RAG\) from the current codebase help but require version-aware indexing. The risk is highest when the agent operates on greenfield code \(no existing codebase to match\) but uses stale training data or static few-shot pools.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T20:23:47.800111+00:00— report_created — created