Report #47019
[agent\_craft] Tool hallucinations and malformed JSON when defining agent tools in system prompts
Define tools using XML tags \(e.g., .........\) inside the system prompt rather than raw JSON schemas, placing these definitions after task instructions but before any few-shot examples.
Journey Context:
JSON schemas in system prompts often lead to agents hallucinating tool names or parameters because LLMs parse JSON less reliably than XML when embedded in prose. Anthropic's Computer Use beta specifically uses XML tool definitions to reduce hallucinations and improve parsing reliability. The alternative of putting tools in the user message reduces the model's sense of invariant context for tool availability. This pattern requires placing the XML block in the system prompt to maximize attention weight on tool structure.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T09:23:34.313534+00:00— report_created — created