agent_k.core.exceptions
Custom exceptions for AGENT-K.
agent_k.core.exceptions
Exception hierarchy for AGENT-K system.
@notice: | Exception hierarchy for AGENT-K system.
@dev: | See module for implementation details and extension points.
@graph: id: agent_k.core.exceptions provides: - agent_k.core.exceptions pattern: exception-hierarchy
@agent-guidance: do: - "Use agent_k.core.exceptions as the canonical home for this capability." do_not: - "Create parallel modules without updating @similar or @graph."
@human-review: last-verified: 2026-01-26 owners: - agent-k-core
(c) Mike Casale 2025. Licensed under the MIT License.
AgentKError
Bases: Exception
Base exception for all AGENT-K errors.
All exceptions in the system inherit from this class, enabling catch-all handling at application boundaries.
@pattern: name: exception-base rationale: "Root exception with context and recoverability metadata."
Attributes:
| Name | Type | Description |
|---|---|---|
context |
Additional context for debugging. |
|
recoverable |
Whether the error can potentially be recovered. |
Source code in agent_k/core/exceptions.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
AgentError
Bases: AgentKError
Base exception for agent-related errors.
@pattern: name: exception-category rationale: "Category base for agent execution errors."
Source code in agent_k/core/exceptions.py
87 88 89 90 91 92 93 | |
AgentExecutionError
Bases: AgentError
Raised when agent execution fails.
@pattern: name: exception-specific rationale: "Captures agent name and cause for debugging."
Source code in agent_k/core/exceptions.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
ToolExecutionError
Bases: AgentError
Raised when a tool execution fails.
@pattern: name: exception-specific rationale: "Captures tool name and arguments for debugging."
Source code in agent_k/core/exceptions.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
OutputValidationError
Bases: AgentError
Raised when agent output fails validation.
@pattern: name: exception-specific rationale: "Captures validation errors for structured output failures."
Source code in agent_k/core/exceptions.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
AdapterError
Bases: AgentKError
Base exception for adapter-related errors.
@pattern: name: exception-category rationale: "Category base for platform adapter errors."
Source code in agent_k/core/exceptions.py
149 150 151 152 153 154 155 | |
PlatformConnectionError
Bases: AdapterError
Raised when connection to platform fails.
@pattern: name: exception-specific rationale: "Captures platform name for connection failures."
Source code in agent_k/core/exceptions.py
158 159 160 161 162 163 164 165 166 167 168 | |
AuthenticationError
Bases: AdapterError
Raised when platform authentication fails.
@pattern: name: exception-specific rationale: "Non-recoverable authentication failure."
Source code in agent_k/core/exceptions.py
171 172 173 174 175 176 177 178 179 180 181 | |
RateLimitError
Bases: AdapterError
Raised when platform rate limit is exceeded.
@pattern: name: exception-specific rationale: "Recoverable with retry_after hint for backoff."
Attributes:
| Name | Type | Description |
|---|---|---|
retry_after |
Seconds to wait before retry. |
Source code in agent_k/core/exceptions.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
CompetitionError
Bases: AgentKError
Base exception for competition-related errors.
@pattern: name: exception-category rationale: "Category base for Kaggle competition errors."
Source code in agent_k/core/exceptions.py
201 202 203 204 205 206 207 | |
CompetitionNotFoundError
Bases: CompetitionError
Raised when competition does not exist.
@pattern: name: exception-specific rationale: "Non-recoverable missing competition."
Source code in agent_k/core/exceptions.py
210 211 212 213 214 215 216 217 218 219 220 221 222 | |
CompetitionRulesNotAcceptedError
Bases: CompetitionError
Raised when competition rules have not been accepted.
@pattern: name: exception-specific rationale: "Non-recoverable until user accepts rules manually."
Source code in agent_k/core/exceptions.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
SubmissionError
Bases: CompetitionError
Raised when submission fails.
@pattern: name: exception-specific rationale: "Captures submission context for retry logic."
Source code in agent_k/core/exceptions.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
DeadlinePassedError
Bases: CompetitionError
Raised when competition deadline has passed.
@pattern: name: exception-specific rationale: "Non-recoverable deadline expiration."
Source code in agent_k/core/exceptions.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | |
EvolutionError
Bases: AgentKError
Base exception for evolution-related errors.
@pattern: name: exception-category rationale: "Category base for evolutionary algorithm errors."
Source code in agent_k/core/exceptions.py
278 279 280 281 282 283 284 | |
ConvergenceError
Bases: EvolutionError
Raised when evolution fails to converge within limits.
@pattern: name: exception-specific rationale: "Captures evolution progress for analysis."
Source code in agent_k/core/exceptions.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |
PopulationExtinctError
Bases: EvolutionError
Raised when all population members fail fitness evaluation.
@pattern: name: exception-specific rationale: "Non-recoverable population extinction."
Source code in agent_k/core/exceptions.py
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | |
FitnessEvaluationError
Bases: EvolutionError
Raised when fitness evaluation fails.
@pattern: name: exception-specific rationale: "Captures solution and execution context for debugging."
Source code in agent_k/core/exceptions.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
MemoryError
Bases: AgentKError
Base exception for memory-related errors.
@pattern: name: exception-category rationale: "Category base for memory and checkpoint errors."
Source code in agent_k/core/exceptions.py
340 341 342 343 344 345 346 | |
CheckpointError
Bases: MemoryError
Raised when checkpoint operations fail.
@pattern: name: exception-specific rationale: "Captures checkpoint name and operation for debugging."
Source code in agent_k/core/exceptions.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | |
MemoryCapacityError
Bases: MemoryError
Raised when memory capacity is exceeded.
@pattern: name: exception-specific rationale: "Captures size metrics for capacity planning."
Source code in agent_k/core/exceptions.py
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 | |
GraphError
Bases: AgentKError
Base exception for graph-related errors.
@pattern: name: exception-category rationale: "Category base for state machine errors."
Source code in agent_k/core/exceptions.py
383 384 385 386 387 388 389 | |
StateTransitionError
Bases: GraphError
Raised when state transition is invalid.
@pattern: name: exception-specific rationale: "Captures transition context for state machine debugging."
Source code in agent_k/core/exceptions.py
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | |
PhaseTimeoutError
Bases: GraphError
Raised when a phase exceeds its timeout.
@pattern: name: exception-specific rationale: "Captures timing metrics for timeout analysis."
Source code in agent_k/core/exceptions.py
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | |
classify_error
classify_error(
exc: Exception,
) -> tuple[ErrorCategory, RecoveryStrategy]
Classify errors into recovery categories and strategies.
@notice: | Maps exceptions to error categories and recovery strategies.
@dev: | Used by error handlers to determine retry vs abort behavior. Returns (category, strategy) tuple for the exception type.
Source code in agent_k/core/exceptions.py
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | |