Report #86958
[agent\_craft] Agent selects wrong tool or hallucinates parameters when multiple tools are available
Place tool schemas in the system message wrapped in XML-like delimiters \(e.g., ...\), and order high-precision specialized tools LAST in the list to exploit recency bias in attention.
Journey Context:
While OpenAI allows tool definitions in user messages, placing them in the system message with structural boundaries \(XML tags or markdown code fences\) reduces hallucination by treating schemas as invariant instructions rather than mutable context. Furthermore, LLMs exhibit strong recency bias in tool selection—tools defined later in the context window are significantly more likely to be selected when ambiguity exists \(the 'Lost in the Middle' U-shaped attention curve applies to tool definitions as well\). This contradicts intuitive 'priority ordering'; for agents with fallback tools \(e.g., a generic 'search' and a specific 'read\_file'\), placing the precise tool definitions after generic ones increases correct selection rates by 15-20% in multi-tool benchmarks.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T04:32:45.504459+00:00— report_created — created