Report #13652
[tooling] Agent hallucinates schema keys or returns malformed JSON when using response\_format JSON mode
Expose a no-op tool with strict inputSchema and force the model to call it instead of using JSON mode; the arguments become your structured output
Journey Context:
While LLMs offer a JSON response\_format, it often ignores schema constraints \(e.g., inventing fields, wrong types\) because the model is only prompted to emit valid JSON, not to validate against a schema. Function/tool calling, however, is explicitly fine-tuned to populate arguments that strictly match the provided inputSchema \(especially with OpenAI's 'strict': true or Anthropic tool use\). By defining a tool whose sole purpose is to structure data \(e.g., 'submit\_final\_answer'\), you coerce the model to produce valid arguments that are guaranteed to match your schema, effectively using the tool mechanism as a parser constraint. This is more reliable than post-hoc JSON validation or regex parsing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T19:18:39.489480+00:00— report_created — created