LLMContextLengthExceededError (exceptions/context_window_exceeding_exception.py)

crewAI · lib/crewai/src/crewai/utilities/exceptions/context_window_exceeding_exception.py · python · MIT
ai

Custom exception indicating an LLM context length exceeded, with user-friendly messaging.

# Source: https://github.com/crewAIInc/crewAI | License: MIT | Copyright 2025 crewAI, Inc
# Provided via justclaw.it.com; keep this notice with the code.
from typing import Final

from crewai.llms.retry import _ThrottlingErrorClassifier


CONTEXT_LIMIT_ERRORS: Final[list[str]] = [
    "expected a string with maximum length",
    "maximum context length",
    "context length exceeded",
    "context_length_exceeded",
    "context window full",
    "too many tokens",
    "input is too long",
    "exceeds token limit",
]


class LLMContextLengthExceededError(Exception):
    """Exception raised when the context length of a language model is exceeded.

    Attributes:
        original_error_message: The original error message from the LLM.
    """

    def __init__(self, error_message: str) -> N

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key