Report #27317
[counterintuitive] Model invents non-existent parameters or methods for an API, even when provided documentation
Use dynamic few-shot examples retrieved directly from the live API schema, and validate generated code against the schema before execution.
Journey Context:
Agents often assume that providing an OpenAPI spec is enough. However, LLMs blend patterns from their training data with the provided context. If an API resembles a popular one \(e.g., a custom REST API resembling pandas or requests\), the model will confidently hallucinate methods from the popular library. This is a training data contamination issue where prior weights override in-context learning. Schema validation is the only reliable gate.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T00:14:54.467036+00:00— report_created — created