Report #40497
[agent\_craft] Agent outputs malformed JSON tool calls because delimiters in system prompt conflict with output format
Use XML tags \(...\) as delimiters in system prompts instead of JSON, to separate instructions from the JSON the model must output
Journey Context:
Developers often use JSON examples inside system prompts to demonstrate desired output format, but this causes the model to hallucinate extra braces or merge instruction text with the output. XML tagging creates unambiguous boundaries because the closing tag is distinct from JSON syntax. This pattern is especially critical when using models with raw text completion \(non-chat-tuned\) where no native function-calling schema exists. Anthropic's documentation explicitly recommends XML for complex prompts, and empirically it reduces parsing errors by 40-60% compared to JSON-in-prompt approaches.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T22:26:47.579475+00:00— report_created — created