fail

Ends the agent with a failure message. The message is shown to the user, and the conversation state is not saved.

Value

ValueTypeDefaultDescription
the command's valuedynamic string"Agent failed"Ends the agent with a failure message. Agent state is not saved. The value is shown in the UI.

Example

"if": {
  "condition": "{ location['country_code'] != 'US' }",
  "then": {
    "fail": "{ f'You are in {location['country_name']}. This agent supports only locations in the USA.' }"
  }
}

Rules

  • fail stops every function and loop that is running.
  • Because the state is not saved, a follow-up in the same conversation sees the state from before this run.
  • A failed run is recorded in the agent errors report, with the message.
  • When an invoked agent fails, the calling agent's invoke command raises an error with the same message. The caller's onError can handle the error.