Report #45922
[agent\_craft] Agent generates malformed or hallucinated JSON tool arguments when schema is complex or nested
Use XML tags instead of JSON for tool argument formatting in the prompt: wrap each parameter in value tags. This leverages the XML bias in Claude/Anthropic models and reduces JSON syntax errors \(missing quotes, trailing commas\) common in LLM output.
Journey Context:
While OpenAI models default to JSON mode, Anthropic's Claude is fine-tuned on XML-heavy training data. Forcing JSON on Claude often results in 'JSON mode' artifacts like markdown fences or partial objects. XML is more robust to whitespace and doesn't require escaping quotes inside strings. The pattern is to describe the tool in natural language then provide the schema via XML examples. Alternatives like 'JSON mode' API flags are model-specific and less portable.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T07:33:22.462408+00:00— report_created — created