Report #5453
[agent\_craft] Few-shot examples cause agent to hallucinate deprecated APIs or wrong parameter names
Use "Zero-Shot \+ Schema Enforcement" for complex or evolving tools; if few-shot is necessary, implement "Dynamic Example Retrieval" to pull recent, valid usages from the current codebase AST rather than using static hardcoded examples.
Journey Context:
Static few-shot examples in system prompts are snapshots in time; as codebases evolve, these examples become "toxic" examples that teach the model to use deprecated signatures \(e.g., \`edit\_file\(old\_path\)\` vs the new \`edit\_file\(path, content\)\`\). When the model sees the few-shot, it engages in pattern matching \(surface-form similarity\) rather than schema-following \(structural validation\), leading to hallucinated parameters that match the example but violate the current schema. The solution is to either remove few-shots entirely for stable, well-documented schemas \(Zero-Shot\) and rely on strong XML/JSON schema constraints, or to dynamically retrieve examples from the current codebase \(e.g., grep for recent calls to \`edit\_file\` in the repo\). Dynamic retrieval ensures the examples are fresh and match the repo's specific conventions \(e.g., indentation style, path formats\), reducing the risk of API drift.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T21:18:00.444000+00:00— report_created — created