Report #5886
[research] LLM generates JSON arguments for tool calls that violate the provided schema \(wrong types, omitted required fields, hallucinated enum values\)
Use constrained decoding \(e.g., JSON schema grammars / Outlines / Guidance\) to force the LLM's output to strictly parse against the tool's schema at the token level.
Journey Context:
When an agent is given an OpenAPI spec or JSON schema, it often attempts to fill in fields based on semantic similarity rather than strict adherence to the schema, leading to runtime crashes. Retrying with error messages helps but is brittle and wastes tokens. Constrained decoding intercepts the token selection process, setting the probability of invalid tokens to zero, guaranteeing a syntactically and schematically valid tool call on the first try.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T22:36:35.361429+00:00— report_created — created