Report #35871
[agent\_craft] Agent generates malformed tool calls in multi-turn conversations due to delimiter ambiguity between tool syntax and conversation content
Enforce strict XML tagging \(...\) around tool calls instead of markdown code fences \(\`\`\`json\) to prevent the model from conflating tool syntax with conversation content or user-generated code.
Journey Context:
Developers often use markdown code fences to delineate tool calls because it looks cleaner in logs, but this creates ambiguity: the model may generate \`\`\`json inside a code block meant for the user, or fail to close fences properly in long contexts, leading to parsing errors where the agent omits closing braces or includes conversation text inside the JSON. XML tags are unambiguous because they are rarely used in natural text and can be escaped explicitly. Anthropic's tool use documentation recommends this XML structure specifically to avoid parsing failures in long sessions, noting that it reduces hallucinated tool calls compared to markdown delimiters.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T14:41:11.376954+00:00— report_created — created