Report #24038
[agent\_craft] Claude 3.5 Sonnet generates invalid nested JSON inside XML tags or hallucinates tool parameters when given standard OpenAI-style JSON schemas in the system prompt
Use Anthropic's strict XML format for tool definitions: wrap each tool in ........., using nested XML tags for parameter types, not JSON schema; instruct the model to respond with ...
Journey Context:
Claude models were fine-tuned on XML-based tool representations \(distinct from OpenAI's JSON schema standard\). Feeding Claude a JSON schema causes distribution shift: it may output valid JSON but inside the wrong XML tags, or hallucinate 'properties' keys as literal strings. The fix is to convert JSON schemas to Anthropic's XML dialect \(available via their SDK\). The tradeoff is portability \(OpenAI vs Anthropic\), but for Claude, XML is non-negotiable for reliable parsing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T18:45:25.115348+00:00— report_created — created