How To Write Error Messages An AI Agent Can Resolve
An AI agent is working through a task on your product: filling a form, calling your API, following your setup guide. It hits an error. What happens next depends entirely on what your error message says. “Something went wrong” stops the agent cold, because there is nothing to act on. “Email address already registered, use a different one or sign in” lets it recover and keep going.
This is a new audience for an old craft. Error messages used to be read only by humans, who could use judgment to fill the gaps. Now a growing share of them are read by agents that can only act on what the message literally says. A vague error that a person could muddle through is a dead end for automation, and increasingly that automation is a user trying to get something done through your product.
Writing errors that an agent can resolve turns out to be the same as writing errors a human can resolve, done more strictly.
An Agent Can Only Act On What The Message States
A person reading “invalid input” can guess which field, try a few things, and often recover. An agent takes the message at face value: if it does not name the field, the agent does not know which field, and it either stalls or retries blindly. The message is the entire interface to the problem.
So the standard goes up. Every error an agent might hit needs to name what failed, why, and what a valid next action is, in the text of the message itself. Nothing can be left to inference, because the reader doing the inferring has no context beyond the string you returned. This is the error-handling side of writing documentation an AI agent can follow.
Name The Cause And The Fix In The Same Message
The pattern is cause plus remedy, both stated, both specific.
Before:
Error: request failed. Please try again.
After:
Error: the file is 2.3 GB, over the 2 GB upload limit. Compress the file or split it into parts under 2 GB, then retry.
The second version gives an agent everything it needs to recover without a human: the exact cause, the specific limit, and two concrete remedies. “Please try again” invites the one thing that will not work, retrying an identical request that will fail identically. An agent told to try again does, repeatedly, which is worse than stopping.
State The Limit, Not Just The Violation
Half-specific errors are a common trap. “File too large” names the cause but not the boundary, so an agent knows something is wrong but not what would be right. It cannot tell whether to shave off a little or a lot. Always include the actual threshold, the allowed values, or the expected format, so the reader knows not just that it failed but what success would look like.
Before:
Error: unsupported format.
After:
Error: unsupported format “.tiff”. Supported formats are .png, .jpg, and .webp. Convert the image and retry.
The second version tells the agent exactly which formats would work, so it can convert and continue. Naming the valid set turns a dead end into a step. This is the same logic as putting the expected result into each instruction in a how-to an AI assistant reproduces correctly.
Keep The Message Stable And Literal
Agents often match on message text, so an error that changes wording every release, or buries the useful part inside a stack trace, is hard to act on reliably. Keep the human-readable cause and remedy at the front of the message, in consistent wording, with any diagnostic detail after it. A stable, literal message is one an agent can learn to handle, where a decorative or shifting one is not.
Resist the urge to make errors cute. Personality in an error message adds words an agent has to parse past to reach the fact, and it rarely helps the human either when they are actually stuck. Plain, specific, and consistent beats clever.
A Wrivio Context For Rewriting A Vague Error
Auditing error strings is tedious, which is why so many stay vague. A rewrite pass makes a whole set of them specific quickly, and you can feed it your real limits so the remedies are true.
Try this instruction:
Rewrite this error message so it names the specific cause, states the exact limit or allowed values, and gives one or two concrete remedies the reader can act on, with the cause and remedy at the front before any diagnostic detail. Keep every real limit, value, and format exactly as written. Do not invent limits or remedies that are not in the original.
Press Ctrl+Shift+Space, paste the message and its real constraints, and check the diff. The fact-preservation clause matters most here: an error that states a wrong limit is worse than a vague one, because it sends the agent confidently toward a fix that will not work.
The Same Message Unblocks Your Human Users
None of this is agent-only. A human staring at “something went wrong” is as stuck as an agent, and a human who reads “the file is over the 2 GB limit, compress it and retry” fixes it in seconds. Writing errors for the strict reader, the one that can only use what the string literally says, produces messages that unblock everyone. For a sense of how much agents act on what they read rather than infer, the research on agentic search evaluation is a useful grounding, and how to vet an agentic feature before you enable it covers the other side of letting agents act in your systems.
Common Questions
Why does a vague error message stop an AI agent?
Because an agent can only act on what the message literally states, so an error that does not name the field, cause, or fix leaves it nothing to work with; it either stalls or retries the same failing request, where a human could guess and muddle through.
What should an agent-friendly error message include?
The specific cause, the exact limit or allowed values, and one or two concrete remedies, all stated in the message text with the cause and fix at the front before any stack trace or diagnostic detail.
Why include the limit and not just the error?
Because naming only the violation tells the agent something is wrong but not what would be right, so it cannot tell how to correct the input; stating the actual threshold or allowed set shows what success looks like and turns a dead end into a step.
Does writing errors for agents hurt human readability?
No, the opposite; a message that names the cause, the limit, and the fix unblocks a human as fast as an agent, while “something went wrong” leaves both equally stuck.
Download Wrivio for Windows to rewrite a vague error into one that names the cause, the limit, and the fix an agent or a person can act on.
Read Next
Why AI Search Skips Your Landing Page
Your landing page converts humans and gets ignored by answer engines. The reason is that persuasion copy answers no question. How to make a sales page citable too.
Where To Put The Date On A Page AI Search Trusts
Answer engines weigh freshness, but a page with three conflicting dates confuses them. Where to show the date, which date matters, and how to signal a real update.
How To Caption An Image AI Search Can Use
Multimodal AI search reads images, but it leans on your caption and alt text to know what they mean. How to describe an image so an answer engine can cite it.
How To Batch Your Writing To Protect Focus
Replying to messages one at a time shreds your attention all day. How to batch your writing into focused blocks, and where a fast rewrite tool fits the habit.
This article is filed underContent & SEO, which has 150 articles.