Report #29559
[frontier] Agents generate malformed JSON tool arguments or hallucinate parameters not in the schema, causing runtime exceptions in downstream APIs
Replace JSON mode with strict structured generation \(OpenAI's \`strict: true\`, Anthropic's \`tool\_choice\` with forced schemas, or Outlines/Guidance libraries\) that constrains token generation to match the JSON schema at the grammar level, not just post-hoc validation
Journey Context:
Common approach is to ask LLM to output JSON and then \`json.loads\(\)\`, catching exceptions and retrying. This fails because LLMs can generate valid JSON that doesn't match the tool schema \(wrong types, missing required fields\) or invalid syntax due to token sampling randomness. The fix is 'constrained decoding' or 'structured generation' where the logits are masked during generation to only allow tokens that satisfy the JSON schema. OpenAI's \`strict: true\` \(JSON mode v2\) uses this internally. Anthropic supports \`tool\_choice: \{type: 'tool', name: '...'\}\` with guaranteed schema adherence. For open models, Outlines or Guidance libraries implement grammar-constrained generation. This eliminates parse errors and schema violations at the source, ensuring tools receive valid arguments that strictly conform to the defined interface without retry loops.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T04:00:18.993253+00:00— report_created — created