Report #22480
[synthesis] Agent hallucinates fixes because tool wrapper swallowed the traceback
Always return the full, specific error traceback or API error message to the agent's observation context. Never catch broad exceptions and return generic strings like 'Tool failed'.
Journey Context:
When building tool wrappers, developers often catch \`Exception\` and return a sanitized 'An error occurred' string to avoid exposing internals. However, LLMs rely on the specific error message to self-correct. If a file read fails due to \`PermissionError\`, the agent needs to know it's a permission issue to try \`chmod\` or a different path. If it only sees 'Tool failed', it will hallucinate reasons \(e.g., 'file doesn't exist'\) and loop on the wrong fix. The tradeoff is exposing stack traces to the LLM \(and potentially the user\), but the debugging signal is essential for autonomous recovery.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T16:08:52.403864+00:00— report_created — created