Errors
Last updated
Was this helpful?
Last updated
Was this helpful?
Agents can raise errors, for example when the underlying model fails to generate a response or when there are content moderation issues.
All errors are wrapped in a WorkflowAIError
that contains details about what happened.
The most interesting fields are:
code
is a string that identifies the type of error, see the file for more details
message
is a human readable message that describes the error
The WorkflowAIError
is raised when the agent is called, so you can handle it like any other exception.
Sometimes, the LLM outputs an object that is partially valid, good examples are:
the model context window was exceeded during the generation
the model decided that a tool call result was a failure
In this case, an agent that returns an output only will always raise an InvalidGenerationError
which
subclasses WorkflowAIError
.
However, an agent that returns a full run object will try to recover from the error by using the partial output.