Raise `ModelRequestRejectedError` for HTTP 413

Merged
AD
22d ago
+9-11

An HTTP 413 ("request too large") came back as a bare ModelHTTPError. For example, Anthropic's request_too_large raised a plain ModelHTTPError, so except ModelRequestRejectedError and category-based retry policies didn't catch it.

This PR adds 413 to the shared http_status_category table as ModelRequestRejectedError, as decided in the issue: every listed provider uses 413 for "request too large", and a retry can't fix it. Provider-specific checks still run first, so a 413 that reports a context-window overflow still becomes ModelContextWindowExceededError.

Temporal's _DEFAULT_NON_RETRYABLE_MODEL_ERRORS (durable_exec/temporal/_durability.py) includes ModelRequestRejectedError, so a 413 in a Temporal activity is now not retried by default. That is intended: retrying the same oversized request can't succeed.

Tests and docs:

  • The two tests that pinned 413 as a bare ModelHTTPError are updated: test_error_categories.py and test_anthropic_batch.py.
  • The docs table, docstrings and the agent skill's error list now mention 413.

Left out:

  • 408: maps to ModelTimeoutError and needs the ModelTimeoutError docs rewritten.
  • 424: Bedrock-specific originalStatusCode handling.
  • 498: Groq-only.

Each is a separate, provider-aware change per the decision comment.

Checklist

  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration, release note, and exact API-check waiver.
  • PR title is fit for the release changelog.

Summary by cubic

Maps HTTP 413 ("request too large") to ModelRequestRejectedError instead of a bare ModelHTTPError, so except ModelRequestRejectedError and category-based retry policies now catch it. Provider-specific checks still run first, so a 413 that signals context-window overflow still becomes ModelContextWindowExceededError.

Docs and tests are updated: the error-category docs, the ModelRequestRejectedError docstring, and the agent skill's error list mention 413, and the tests that pinned 413 as a bare ModelHTTPError now expect ModelRequestRejectedError.

Not covered here: 408 (ModelTimeoutError), 424 (Bedrock-specific handling), and 498 (Groq-only), which need provider-aware changes.