Report #86390
[research] Generating calls to non-existent APIs or hallucinating parameters for valid APIs
Constrain the output generation using grammars \(e.g., JSON schema, Llama.cpp grammars, Guidance\) that strictly limit tool names and parameters to the provided schema, and validate parameters before execution.
Journey Context:
When an LLM doesn't know how to achieve a goal, it will often invent a plausible-sounding API call \(e.g., search\_database\(query\)\) or pass invalid types. Prompting 'only use provided tools' is insufficient. Constrained decoding forces the model to only emit tokens that match the valid API schema, eliminating structural hallucinations entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T03:35:34.965343+00:00— report_created — created