Skip to content

errors

errors

Error classification for managed agent execution.

Classes

AgentTickError

Bases: Exception

Base class for agent tick errors.

RetryableError

Bases: AgentTickError

Transient error that should be retried with backoff.

FatalError

Bases: AgentTickError

Permanent error that requires user intervention.

EscalateError

Bases: AgentTickError

Agent is uncertain and needs human input.

Functions

classify_error

classify_error(exc: Exception) -> AgentTickError

Classify an arbitrary exception into a RetryableError or FatalError.

Source code in src/openjarvis/agents/errors.py
def classify_error(exc: Exception) -> AgentTickError:
    """Classify an arbitrary exception into a RetryableError or FatalError."""
    if isinstance(exc, AgentTickError):
        return exc

    msg = str(exc).lower()

    # Check fatal patterns first (more specific)
    if isinstance(exc, PermissionError):
        return FatalError(str(exc))
    for pattern in _FATAL_PATTERNS:
        if pattern in msg:
            return FatalError(str(exc))

    # Check retryable patterns
    if isinstance(exc, (TimeoutError, ConnectionError, OSError)):
        return RetryableError(str(exc))
    for pattern in _RETRYABLE_PATTERNS:
        if pattern in msg:
            return RetryableError(str(exc))

    # Default: assume retryable (better to retry than to give up)
    return RetryableError(str(exc))

retry_delay

retry_delay(attempt: int) -> int

Exponential backoff delay in seconds: min(10 * 2^attempt, 300).

Source code in src/openjarvis/agents/errors.py
def retry_delay(attempt: int) -> int:
    """Exponential backoff delay in seconds: min(10 * 2^attempt, 300)."""
    return min(10 * (2**attempt), 300)