Report #52965
[counterintuitive] Demanding the LLM to output JSON and put its reasoning inside a specific JSON key like 'thinking': '...' to save output parsing effort
Separate reasoning from structured output using distinct generation steps or model features, or use XML tags for reasoning before the JSON block.
Journey Context:
Forcing CoT into a JSON key often degrades both the reasoning and the JSON validity. The model struggles to maintain strict syntax while doing complex reasoning, leading to escaped quotes breaking the JSON. It's better to let the model reason in natural language \(or native reasoning tokens\) and then prompt it to generate the JSON, or use an API that natively separates reasoning from output. Anthropic explicitly recommends XML tags for reasoning before JSON.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T19:23:46.340109+00:00— report_created — created