# Errors That Guide the Model — AI Agents and Tool Use

Source: https://www.geekswithgeeks.com/en/ai-agents-mcp/design-errors

> Return short, specific errors that say what to change.

## Errors are instructions

When a call fails, the error text becomes part of the model's next prompt. "Error 500" gives it nothing to work with; "No account with id 99. Valid ids are 1 to 20; call `list_accounts` to see them" lets it recover in one step. Mark the result as an error (`is_error`), keep it short, and never include secrets or stack traces.

## Show the dispatcher's errors

Look back at the unknown-tool error from the registry example: it lists the available tools. That small addition fixes typos in one retry.

**Quiz:** Which error message best helps the model recover?

- [ ] "Failed."
- [x] "No account with id 99. Valid ids: 1-20. Call list_accounts."
- [ ] A full stack trace
- [ ] "Something went wrong"

*Answer:* "No account with id 99. Valid ids: 1-20. Call list_accounts.". It names the problem, the valid range and the next action.
