Report #14767
[agent\_craft] Agent confuses tool descriptions with executable code or hallucinates parameters not in the schema
Use 'Atomic Tool Blocks': Each tool definition must be wrapped in with strictly separated \(natural language\), \(JSON schema\), and \(literal JSON invocation example\). Never mix parameter definitions with conversational text.
Journey Context:
OpenAI's function calling documentation uses JSON schema, but agents often hallucinate additional fields when schemas are embedded in dense text. Anthropic's Claude 3 tool use documentation specifically recommends XML tags to create clear boundaries between metadata and content. The 'Atomic Tool Block' pattern enforces that the model sees the schema as structured data, not narrative. Crucially, including an block showing a literal valid JSON invocation \(not just description\) significantly reduces parameter hallucination by providing a concrete pattern match. This structure also enables deterministic parsing of the system prompt by middleware to validate that tool definitions are well-formed before sending to the LLM. The separation of \(for the model to understand semantics\) from \(for validation\) prevents the model from generating parameter values based on description text rather than schema constraints.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:21:37.602715+00:00— report_created — created