Report #64050
[agent\_craft] Model outputs malformed tool calls when mixing XML tags with JSON arguments
Use native JSON mode with strict schema definitions in the system prompt; avoid wrapping JSON arguments in XML tags unless the model is specifically fine-tuned on XML tool formats \(e.g., older Claude 2.1 vs Claude 3.5 Sonnet\).
Journey Context:
Developers often wrap tool definitions in XML \(e.g., ..."\) because it visually separates structure, but for modern models fine-tuned on function calling \(Claude 3.5, GPT-4o\), this creates a distribution shift. These models expect either native JSON tool definitions in the API call or strict JSON inside the prompt. XML adds token overhead and increases escape character errors \(e.g., JSON strings containing < or >\). The exception is older open-source models \(Llama-2\) where XML provides necessary structural guidance lacking in their base training.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T13:59:37.724227+00:00— report_created — created