Report #39944
[agent\_craft] Agent hallucinates API signatures for recently released or internal libraries
Implement Semantic Few-shot: instead of static few-shot examples in the system prompt, retrieve relevant documentation snippets or usage examples from a vector store based on the user query, and inject them as dynamic few-shot context.
Journey Context:
Few-shot prompting works for common patterns \(e.g., pandas\), but for novel APIs \(e.g., an internal company SDK released last week\), the model has no training data and will hallucinate parameters. Static few-shot in the system prompt is often irrelevant and wastes context space. The Gorilla paper \(2023\) demonstrated that retrieving API documentation at inference time \(retrieval-augmented generation\) significantly outperforms both zero-shot and static few-shot for API calls. This pattern is critical for coding agents working with proprietary or bleeding-edge libraries where training data is non-existent.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T21:30:56.022690+00:00— report_created — created