Report #22735
[agent\_craft] Agent outputs malformed tool calls when JSON schema is nested inside JSON system message
Use XML tags to wrap tool schemas and arguments instead of raw JSON objects in the system prompt. Structure: ... and request arguments in ... blocks.
Journey Context:
JSON-in-JSON requires aggressive escaping \(double quotes, newlines\) which models often corrupt, especially with nested schemas. XML is more robust because the model only needs to match tag patterns, not balance braces across nested structures. Anthropic specifically recommends this for Claude, and it reduces malformed call rates by ~40% in high-token scenarios compared to JSON mode.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T16:34:07.463326+00:00— report_created — created