raise the Anthropic request body limit to 64 MiB - #152
Merged
Merged
Conversation
An image-heavy Claude Code session (490k tokens of screenshots) exceeded the 16 MiB gate, which rejected every subsequent request on that session. 64 MiB matches the Codex image edit cap in `providers::codex::images`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> (cherry picked from commit 6aef599)
Contributor
|
Raising
|
Claude Code sessions with image-heavy histories can exceed the previous 16 MiB request limit. Give Anthropic Messages and Token Counting their own 64 MiB limit while preserving the existing OpenAI-compatible endpoint limit. Return the documented 413 request_too_large response when an Anthropic request exceeds the limit, and cover both Anthropic endpoints at the boundary.
Owner
|
Thanks for this! The larger limit fixes the image-heavy session case nicely. I split the Anthropic limit from the OpenAI-compatible endpoints and corrected oversized Anthropic requests to return 413 request_too_large. Merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
MAX_OPENAI_REQUEST_BYTESis 16 MiB. An image-heavy Claude Code session (~490k tokens of screenshots) pushes the request body past that, and because Claude Code re-sends the full history on every turn, the gate then rejects every subsequent request on that session — the session is unrecoverable without dropping the transcript.Fix
Raise the limit to 64 MiB, matching the Codex image edit cap already used in
providers::codex::images, so the two paths agree on how large an image-bearing request may be.MAX_PROVIDER_STREAM_BYTES(32 MiB) andMAX_SSE_EVENT_BYTES(2 MiB) are untouched — those bound responses, which this does not change.Verification
Tests in
tests/server.rscover the boundary directly:cargo clippy --all-targets -- -D warningsclean,cargo fmt --checkclean, full suite green.🤖 Generated with Claude Code