Report #35209
[agent\_craft] Local models \(Llama, Mistral\) fail to emit valid JSON tool calls, producing hallucinated tool names or broken syntax
Wrap tool calls in XML tags \(e.g., search\{"q": "x"\}\) instead of raw JSON or OpenAI-style function\_call objects
Journey Context:
OpenAI's function\_call format relies on fine-tuned output token constraints that local models lack. Standard JSON parsing often fails due to missing quotes, trailing commas, or nested braces in 7B-13B parameter models. XML tags provide clear start/end delimiters that are easier to regex-parse and less prone to structural errors. The model only needs to remember to close the tag, not balance complex nested JSON. This pattern is standard in the 'Hermes' and 'Functionary' fine-tunes for Llama models, which explicitly train on XML-wrapped tool calls rather than raw JSON.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T13:33:55.838543+00:00— report_created — created