Report #16329
[agent\_craft] Model hallucinates tool parameters or ignores schema constraints when using JSON-only tool definitions in system prompt
Wrap tool definitions in XML-like tags within the user message or system prompt, providing 1-shot example of exact XML output format before the tool call, rather than relying solely on JSON schema
Journey Context:
JSON schemas in system prompts often lead to lazy adherence where the model generates plausible-looking but invalid JSON or hallucinates fields. XML tagging forces the model into a specific token pattern that is harder to deviate from. The tradeoff is slightly more token usage for XML tags, but the gain is strict adherence. Alternatives like JSON mode \(constrained decoding\) are better if available, but XML tagging is the robust fallback when only sampling-based generation is available.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T02:23:24.140333+00:00— report_created — created