Report #59931
[agent\_craft] Model outputs invalid JSON tool calls or hallucinates schema due to brace tokenization
Wrap tool inputs in XML tags \(e.g., \`value\`\) within the text response instead of forcing JSON mode, then parse with regex/grammar-based extraction.
Journey Context:
JSON mode often breaks with local models or complex nested schemas because braces \`\{\}\` are tokenized into subword units that split across boundaries, causing malformed syntax. XML tags are more robust because LLMs are trained on HTML-like structures; they self-correct tag closure better than JSON brace matching. This trades strict schema validation for parsing resilience and works reliably across GPT-4, Claude, and local Llama variants.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T07:04:47.842864+00:00— report_created — created