Report #12410
[agent\_craft] Tool call parsing fails when code strings contain quotes or newlines
Use XML tag formatting for tool calls instead of JSON when arguments contain multi-line code blocks; escape CDATA sections if necessary.
Journey Context:
JSON tool schemas require escaping newlines and quotes inside string arguments. When agents pass generated code as arguments \(e.g., for a 'write\_file' tool\), the escaping frequently fails or the JSON becomes malformed. XML tags with explicit delimiters \(as used by Anthropic's tool use specification\) are robust to raw code strings because the parser looks for closing tags, not quote balancing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T15:52:57.160663+00:00— report_created — created