Skip to content

pydantic_ai.exceptions

ModelRetry

Bases: Exception

Exception raised when a retriever function should be retried.

The agent will return the message to the model and ask it to try calling the function/tool again.

message instance-attribute

message: str = message

The message to return to the model.

UserError

Bases: RuntimeError

Error caused by a usage mistake by the application developer — You!

message instance-attribute

message: str = message

Description of the mistake.

UnexpectedModelBehaviour

Bases: RuntimeError

Error caused by unexpected Model behavior, e.g. an unexpected response code.

message instance-attribute

message: str = message

Description of the unexpected behavior.

body instance-attribute

body: str | None = dumps(loads(body), indent=2)

The body of the response, if available.