Report #82465
[research] Agents hallucinate success because tool execution errors are returned as unstructured strings, which the LLM interprets as valid data
Enforce structured error handling in tool schemas: tools must return a structured JSON object with a success boolean field and an error\_message, and the agent's system prompt must explicitly instruct it to halt or retry upon success: false.
Journey Context:
When a Python tool throws an exception and the stack trace is passed back as the tool result, the LLM often tries to helpfully incorporate the error text into its next step, leading to bizarre hallucinations. The LLM doesn't natively distinguish between a successful string output and an error string. Wrapping all tool outputs in a strict schema forces the agent to programmatically check the success state before proceeding, making tool failures observable and recoverable.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T21:00:29.894647+00:00— report_created — created