Report #66037
[research] Agent invents non-existent parameters or methods for standard library APIs
Enforce a read-before-write constraint: force the agent to output the actual docstring or source code signature of an API before it is allowed to write a call to that API. Alternatively, use constrained decoding against a JSON schema of the API.
Journey Context:
LLMs trained on vast code corpora will confidently mix up API versions or invent parameters that seem logically consistent \(e.g., adding a \`timeout\` parameter to a function that doesn't support it\). This stems from the model generalizing syntax patterns rather than memorizing exact signatures. Prompting the model to 'be careful' doesn't work; forcing it to ground its generation in the actual API definition via a tool call or RAG step eliminates the parameter hallucination failure mode.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T17:19:24.428750+00:00— report_created — created