aboutsummaryrefslogtreecommitdiff
path: root/autogpts/autogpt/autogpt/agents/utils/exceptions.py
blob: 704922b0aa33ce4df367f903fe241c67336b033e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from typing import Optional


class AgentException(Exception):
    """Base class for specific exceptions relevant in the execution of Agents"""

    message: str

    hint: Optional[str] = None
    """A hint which can be passed to the LLM to reduce reoccurrence of this error"""

    def __init__(self, message: str, *args):
        self.message = message
        super().__init__(message, *args)


class AgentTerminated(AgentException):
    """The agent terminated or was terminated"""


class ConfigurationError(AgentException):
    """Error caused by invalid, incompatible or otherwise incorrect configuration"""


class InvalidAgentResponseError(AgentException):
    """The LLM deviated from the prescribed response format"""


class UnknownCommandError(AgentException):
    """The AI tried to use an unknown command"""

    hint = "Do not try to use this command again."


class DuplicateOperationError(AgentException):
    """The proposed operation has already been executed"""


class CommandExecutionError(AgentException):
    """An error occurred when trying to execute the command"""


class InvalidArgumentError(CommandExecutionError):
    """The command received an invalid argument"""


class OperationNotAllowedError(CommandExecutionError):
    """The agent is not allowed to execute the proposed operation"""


class AccessDeniedError(CommandExecutionError):
    """The operation failed because access to a required resource was denied"""


class CodeExecutionError(CommandExecutionError):
    """The operation (an attempt to run arbitrary code) returned an error"""


class TooMuchOutputError(CommandExecutionError):
    """The operation generated more output than what the Agent can process"""