Skip to content

Exceptions

ContextOverflowError means the request input does not fit the model context, so Agent may shorten the conversation and retry. OutputTokenLimitError means the provider exhausted the configured max_tokens response budget. An output limit failure surfaces without summarization or retry with the unchanged limit. IncompleteResponseError means the provider stopped for some other reason, such as a content filter; it also surfaces without retry.

stirrup.core.exceptions

Custom exceptions for agent framework.

__all__ module-attribute

__all__ = [
    "ContextOverflowError",
    "IncompleteResponseError",
    "OutputTokenLimitError",
]

ContextOverflowError

Bases: Exception

Raised when request input exceeds the model's context capacity.

IncompleteResponseError

Bases: Exception

Raised when a provider returns an incomplete response Stirrup cannot recover from.

Covers stop reasons other than the context and output-budget cases, such as a content filter. Retrying the same request is not expected to help.

OutputTokenLimitError

OutputTokenLimitError(
    *,
    model_slug: str,
    max_tokens: int,
    provider_reason: str,
)

Bases: Exception

Raised when a provider exhausts the configured response-token budget.

Source code in src/stirrup/core/exceptions.py
def __init__(self, *, model_slug: str, max_tokens: int, provider_reason: str) -> None:
    self.model_slug = model_slug
    self.max_tokens = max_tokens
    self.provider_reason = provider_reason
    super().__init__(
        f"Model '{model_slug}' exhausted its configured output budget "
        f"(max_tokens={max_tokens}; provider reason: {provider_reason}). "
        "Increase max_tokens or ask the model for a shorter response."
    )