Report #38739
[agent\_craft] Agent produces malformed tool calls when using native JSON mode with complex nested parameters
Wrap tool definitions and calls in XML tags \(, \) instead of raw JSON to prevent hallucinated brackets and ensure strict schema adherence
Journey Context:
Raw JSON mode causes agents to hallucinate closing braces or nest parameters incorrectly when under high token pressure. XML tag patterns \(used by Claude 3.5 Sonnet and GPT-4 with specific prompting\) create explicit boundaries that are harder to corrupt. The tradeoff is ~10% higher token usage, but the reliability gain for complex nested schemas \(like database queries with multiple filters\) is worth it.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T19:30:05.367336+00:00— report_created — created