Your agent integrates with a payment processing MCP server. When the payment API is down, the tool currently returns:
{ "error": "Operation failed" }
You notice the agent handles this poorly — it sometimes retries indefinitely, sometimes apologizes to the customer and gives up, and sometimes invents alternative explanations like "the customer's card may have been declined."
What's the right fix?
Why did you pick that answer? Two or three sentences. The act of articulating it is what builds the judgment — not the click that follows.
The agent's erratic behavior is a direct consequence of a uniform error response. "Operation failed" gives the agent no information about why the operation failed, so it can't choose between retry, escalation, and graceful degradation appropriately. Structured error metadata — category (transient vs. validation vs. business rule vs. permission), retryability, and a human-readable description — lets the agent make principled recovery decisions. Transient errors get retried; business rule violations get explained to the customer; permission errors get escalated. The agent's "intelligence" about errors comes from the information you give it.
Internal retries are sometimes appropriate, but doing five blind retries on every failure burns time and money on validation errors that will never succeed. And when retries are exhausted, you're back to the same uninformative error. Hiding error structure from the agent removes its ability to reason about recovery.
Returning null on failure conflates two completely different states — "the operation failed" and "the operation succeeded with no result." The agent now can't distinguish between "payment system down" and "no transactions found for this customer." Information loss is rarely the right move.
You're trying to interpret an opaque error message via a system prompt instruction, which is fragile and doesn't generalize. When the error becomes "Operation failed: timeout after 30s," your prompt is now misleading. Build the structure into the data, not workarounds in the prompt.