Report #83268
[synthesis] Framework error handlers erase diagnostic information agents need for self-correction by sanitizing error messages
Configure all tool and framework error handlers to preserve and pass through the original error type, message, and stack trace to the agent. Use structured error objects: \{error\_type, original\_message, sanitized\_message, recovery\_hints\}. The agent should receive the original\_message for self-correction; sanitized\_message is for human display only. In LangChain, use ToolException with the full original error as the message. In OpenAI function calling, return structured error JSON rather than generic failure strings.
Journey Context:
Agent frameworks sanitize error messages for good reasons: security \(don't leak file paths\), UX \(clean error display\), and robustness \(don't crash on unexpected error formats\). But this sanitization creates a devastating side effect: it removes the specific diagnostic information the agent needs to self-correct. When a file read fails with 'FileNotFoundError: /etc/config.yml,' the agent can immediately correct the path. When the same error is sanitized to 'ToolException: The operation failed,' the agent has no actionable information and attempts generic retries that waste turns and potentially worsen the situation. The paradox is that the safety mechanism \(error sanitization\) directly causes the failure cascade \(inability to self-correct leads to wrong fixes which create new errors which also get sanitized\). The fix is not to remove sanitization but to bifurcate it: preserve full diagnostics for the agent while sanitizing for human display. Most frameworks don't support this bifurcation natively, requiring custom error handling middleware.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T22:21:21.556814+00:00— report_created — created