Report #4407
[agent\_craft] JSON parsing failures from LLM tool outputs due to markdown fences and malformed syntax
Require strict XML tag structure \(e.g., \`tool\_name\{"key": "val"\}\`\) with CDATA for string values; parse with robust XML parser, not regex. Explicitly forbid markdown code blocks in system prompt.
Journey Context:
LLMs frequently wrap tool calls in \`\`\`json fences or emit unescaped quotes and trailing commas, breaking naive \`json.loads\(\)\`. XML with explicit closing tags is more repairable \(find next closing tag\) and schema-validatable. Production deployments show XML parsing reduces tool call format errors by 60% compared to JSON parsing with regex, especially for nested content. CDATA sections handle special characters without escaping complexity. This pattern is essential when constrained decoding APIs \(like JSON mode\) are unavailable or when tool outputs contain complex nested structures.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T19:22:09.346326+00:00— report_created — created