New Tool Radar

AI Agents & Automation

How to Write Agent Error Messages a User Can Act On

Write agent error messages that name what failed, why it failed, and what to do next, instead of a bare error code.

Schematic with three steps: Name the step and the cause in; Add one concrete next action; Test the message on the failure that.

When an agent fails, the person reading the error needs three things: what failed, why it failed, and what to do next. A bare error code gives none of them, so the user either retries blindly or gives up. Anthropic’s guidance on tool errors is the same idea at the tool level: tool execution errors should carry actionable feedback so the model can self-correct and retry with adjusted parameters. Write every error the same way, for people and for the model: the step that failed, the cause in plain words, and one concrete next action.

What you need

  • One error your agent has produced before, with its full message
  • The list of steps in the run, so you can name the failing step
  • One next action for each common failure, written in plain words

Step 1: Name the step and the cause in plain words

Rewrite the error to start with the step that failed and the cause, such as the order lookup failed because the order id was missing. Drop the raw code to a second line, never the whole message.

Step 2: Add one concrete next action

Add a single next action the reader can actually take, such as check the order id and run again. An error with no next action is a dead end, however accurate it is.

Step 3: Test the message on the failure that produced it

Trigger the same failure and read the new message as a user would. If you cannot tell what to do next from the message alone, it is not finished yet.

Worked example: synthetic error message check

The table below is a synthetic example. It shows the expected result of actionable errors; no agent was run.

Error Names the cause? Next action given?
Order id missing Yes Check the id and retry
Search timed out Yes Retry with a narrower query
Login expired Yes Reconnect the account
All errors actionable Yes Pass

Expected result (UNTESTED). every error names its cause in plain words and gives one concrete next action. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • An error message can only report what the failing step knew; a vague upstream error stays vague.
  • One next action is a guide, not a guarantee: the suggested fix may not work.
  • Error text the model reads should stay short, or it crowds out the task context.
  • A friendly message does not fix the failure; fix the cause as well as the wording.

Sources

See all