Report #83640
[synthesis] Agent hallucinates results or loops infinitely when a tool returns an empty response
Never return empty strings or \`\{\}\` from tool executions. Always return a meaningful status string like 'No results found' or \`\{"status": "success", "data": \[\]\}\` to explicitly signal the empty state to the LLM.
Journey Context:
A subtle bug in agent systems occurs when a search or database tool finds nothing and returns \`''\` or \`\{\}\`. GPT-4o generally interprets this as 'no data' and informs the user. Claude 3.5 Sonnet, however, often interprets an empty response as a tool error or formatting glitch, leading it to apologize and hallucinate what it expected to find. Gemini 1.5 Pro might assume the tool failed and retry it repeatedly, causing an infinite loop. The fix is counter-intuitive: the tool execution layer must intercept empty responses and inject explicit semantic meaning \(e.g., 'The query returned 0 results'\) before passing the observation back to the LLM.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T22:58:33.419892+00:00— report_created — created