@@ -10,17 +10,17 @@ class AgentError(Exception):
10
10
11
11
12
12
class AgentNoInstructionError (AgentError ):
13
- def __init__ (self , message = 'Instruction must be provided' ):
13
+ def __init__ (self , message : str = 'Instruction must be provided' ) -> None :
14
14
super ().__init__ (message )
15
15
16
16
17
17
class AgentEventTypeError (AgentError ):
18
- def __init__ (self , message = 'Event must be a dictionary' ):
18
+ def __init__ (self , message : str = 'Event must be a dictionary' ) -> None :
19
19
super ().__init__ (message )
20
20
21
21
22
22
class AgentAlreadyRegisteredError (AgentError ):
23
- def __init__ (self , name = None ):
23
+ def __init__ (self , name : str | None = None ) -> None :
24
24
if name is not None :
25
25
message = f"Agent class already registered under '{ name } '"
26
26
else :
@@ -29,7 +29,7 @@ def __init__(self, name=None):
29
29
30
30
31
31
class AgentNotRegisteredError (AgentError ):
32
- def __init__ (self , name = None ):
32
+ def __init__ (self , name : str | None = None ) -> None :
33
33
if name is not None :
34
34
message = f"No agent class registered under '{ name } '"
35
35
else :
@@ -38,7 +38,7 @@ def __init__(self, name=None):
38
38
39
39
40
40
class AgentStuckInLoopError (AgentError ):
41
- def __init__ (self , message = 'Agent got stuck in a loop' ):
41
+ def __init__ (self , message : str = 'Agent got stuck in a loop' ) -> None :
42
42
super ().__init__ (message )
43
43
44
44
@@ -48,7 +48,7 @@ def __init__(self, message='Agent got stuck in a loop'):
48
48
49
49
50
50
class TaskInvalidStateError (Exception ):
51
- def __init__ (self , state = None ):
51
+ def __init__ (self , state : str | None = None ) -> None :
52
52
if state is not None :
53
53
message = f'Invalid state { state } '
54
54
else :
@@ -64,45 +64,47 @@ def __init__(self, state=None):
64
64
# This exception gets sent back to the LLM
65
65
# It might be malformed JSON
66
66
class LLMMalformedActionError (Exception ):
67
- def __init__ (self , message = 'Malformed response' ):
67
+ def __init__ (self , message : str = 'Malformed response' ) -> None :
68
68
self .message = message
69
69
super ().__init__ (message )
70
70
71
- def __str__ (self ):
71
+ def __str__ (self ) -> str :
72
72
return self .message
73
73
74
74
75
75
# This exception gets sent back to the LLM
76
76
# For some reason, the agent did not return an action
77
77
class LLMNoActionError (Exception ):
78
- def __init__ (self , message = 'Agent must return an action' ):
78
+ def __init__ (self , message : str = 'Agent must return an action' ) -> None :
79
79
super ().__init__ (message )
80
80
81
81
82
82
# This exception gets sent back to the LLM
83
83
# The LLM output did not include an action, or the action was not the expected type
84
84
class LLMResponseError (Exception ):
85
- def __init__ (self , message = 'Failed to retrieve action from LLM response' ):
85
+ def __init__ (
86
+ self , message : str = 'Failed to retrieve action from LLM response'
87
+ ) -> None :
86
88
super ().__init__ (message )
87
89
88
90
89
91
class UserCancelledError (Exception ):
90
- def __init__ (self , message = 'User cancelled the request' ):
92
+ def __init__ (self , message : str = 'User cancelled the request' ) -> None :
91
93
super ().__init__ (message )
92
94
93
95
94
96
class OperationCancelled (Exception ):
95
97
"""Exception raised when an operation is cancelled (e.g. by a keyboard interrupt)."""
96
98
97
- def __init__ (self , message = 'Operation was cancelled' ):
99
+ def __init__ (self , message : str = 'Operation was cancelled' ) -> None :
98
100
super ().__init__ (message )
99
101
100
102
101
103
class LLMContextWindowExceedError (RuntimeError ):
102
104
def __init__ (
103
105
self ,
104
- message = 'Conversation history longer than LLM context window limit. Consider turning on enable_history_truncation config to avoid this error' ,
105
- ):
106
+ message : str = 'Conversation history longer than LLM context window limit. Consider turning on enable_history_truncation config to avoid this error' ,
107
+ ) -> None :
106
108
super ().__init__ (message )
107
109
108
110
@@ -117,7 +119,7 @@ class FunctionCallConversionError(Exception):
117
119
This typically happens when there's a malformed message (e.g., missing <function=...> tags). But not due to LLM output.
118
120
"""
119
121
120
- def __init__ (self , message ) :
122
+ def __init__ (self , message : str ) -> None :
121
123
super ().__init__ (message )
122
124
123
125
@@ -127,14 +129,14 @@ class FunctionCallValidationError(Exception):
127
129
This typically happens when the LLM outputs unrecognized function call / parameter names / values.
128
130
"""
129
131
130
- def __init__ (self , message ) :
132
+ def __init__ (self , message : str ) -> None :
131
133
super ().__init__ (message )
132
134
133
135
134
136
class FunctionCallNotExistsError (Exception ):
135
137
"""Exception raised when an LLM call a tool that is not registered."""
136
138
137
- def __init__ (self , message ) :
139
+ def __init__ (self , message : str ) -> None :
138
140
super ().__init__ (message )
139
141
140
142
@@ -191,15 +193,17 @@ class AgentRuntimeNotFoundError(AgentRuntimeUnavailableError):
191
193
192
194
193
195
class BrowserInitException (Exception ):
194
- def __init__ (self , message = 'Failed to initialize browser environment' ):
196
+ def __init__ (
197
+ self , message : str = 'Failed to initialize browser environment'
198
+ ) -> None :
195
199
super ().__init__ (message )
196
200
197
201
198
202
class BrowserUnavailableException (Exception ):
199
203
def __init__ (
200
204
self ,
201
- message = 'Browser environment is not available, please check if has been initialized' ,
202
- ):
205
+ message : str = 'Browser environment is not available, please check if has been initialized' ,
206
+ ) -> None :
203
207
super ().__init__ (message )
204
208
205
209
@@ -217,5 +221,5 @@ class MicroAgentError(Exception):
217
221
class MicroAgentValidationError (MicroAgentError ):
218
222
"""Raised when there's a validation error in microagent metadata."""
219
223
220
- def __init__ (self , message = 'Micro agent validation failed' ):
224
+ def __init__ (self , message : str = 'Micro agent validation failed' ) -> None :
221
225
super ().__init__ (message )
0 commit comments