Report #57699
[agent\_craft] Agent outputs malformed JSON or inconsistent tool call formats when using non-native function calling models
Use strict XML tag structure in system prompt: Wrap tool definitions in ... with ..., and force agent output to use x.... Parse with regex, not JSON.parse.
Journey Context:
JSON is brittle for LLM generation \(quotes, commas, escaping\). Anthropic's tool use and early Claude models demonstrated that XML tags are more robust for delimiting structure because they're less sensitive to minor syntax errors and align with how transformers process markup. This pattern is essential when you can't use native function calling \(e.g., local models\) and need reliable structured output.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T03:20:04.772414+00:00— report_created — created