Preventing an AI voice/chat agent from leaking internal tool stack traces when a downstream API throws 500
While building our customer-facing support agent, we followed the usual advice of returning tool errors to the LLM so it can recover on its own instead of crashing the turn.
That worked great until a downstream billing microservice threw an unhandled psycopg2 exception. Our MCP wrapper caught Exception as e and returned f"Tool failed: {e}" to the model.
Instead of quietly apologizing, the model tried to be "transparent" and told the customer: "Sorry, I couldn't update your invoice because relation billing_ledger_v2 timed out on db-prod-internal."
Obviously we don't want internal table names or stack traces ever reaching the customer prompt—but if we just return "Error" to the model, it doesn't know whether to retry or fix its arguments. How are folks separating retryable LLM hints from private ops logs?