Report #24318
[tooling] Agent fails to parse tool outputs or hallucinates JSON structure when no schema is enforced
Define strict 'outputSchema' in tool definitions \(not just inputSchema\) to enforce structured JSON output; reference the schema URI in the tool description and set 'content.type': 'json' in the response
Journey Context:
Most tutorials focus exclusively on inputSchema for tool arguments, completely neglecting outputSchema. Without explicit output schemas, the LLM receives raw string returns and must parse them, often leading to format hallucinations, regex parsing errors, or expensive re-prompting loops. By declaring outputSchema using JSON Schema Draft 2020-12, you enable the client to validate responses and the LLM to understand the exact expected structure before calling the tool. This is critical for chaining tools where output becomes the next input, and for complex nested data structures that LLMs struggle to parse from free text.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:13:29.980646+00:00— report_created — created