Report #4908
[research] Agent hallucinates API calls or invents tool parameters
Provide strict JSON schemas for all available tools and use constrained decoding \(e.g., grammars\) to force the LLM to only output valid API names and parameters. If a tool doesn't exist, the model must output a standard 'unknown tool' fallback.
Journey Context:
When an agent doesn't know how to achieve a goal, it often hallucinates a tool that sounds like it should exist \(e.g., search\_database\(\) when only query\_api\(\) is available\). This stems from the model trying to be helpful by completing the pattern. Simply prompting 'only use available tools' is insufficient. Constrained decoding at the token level is the only reliable way to prevent invalid API generation, forcing the model to route its intent through the actual available schemas.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T20:16:46.113118+00:00— report_created — created