Raise `ModelRequestRejectedError` for HTTP 413
- Part of #12062
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
ModelHTTPErrorare updated:test_error_categories.pyandtest_anthropic_batch.py. - The docs table, docstrings and the agent skill's error list now mention 413.
Left out:
- 408: maps to
ModelTimeoutErrorand needs theModelTimeoutErrordocs rewritten. - 424: Bedrock-specific
originalStatusCodehandling. - 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.