fix(images): normalize oversized model payloads independently of byte size - #920
Open
breedx wants to merge 3 commits into
Open
fix(images): normalize oversized model payloads independently of byte size#920breedx wants to merge 3 commits into
breedx wants to merge 3 commits into
Conversation
Contributor
Author
|
This fix remains independently reviewable, but full CI hits the existing quoted-tilde completion assertion already addressed separately in #916. I reproduced that exact failure on unpatched
Once the separate completion correction lands, this topic can be requalified on the updated base without widening its scope. |
Contributor
Author
|
greater than 2000px causes models to fail in upstream inference.. |
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.
Images can be small in bytes but still exceed a model's dimension limit. Normalize dimensions across attachment, clipboard and browser-screenshot payloads so compressible screenshots no longer bypass resizing, while keeping saved screenshot files at full resolution.
Problem
The shared image helper gates resizing on encoded byte size. A large, mostly blank screenshot can therefore pass through unchanged. Browser screenshots also bypass that helper, and the file loader uses a different edge limit.
Change
Core scope and overlap
This corrects existing image producers and their shared utility, rather than adding a command or parallel plugin policy. It necessarily touches existing
command_line/image_utils.pyandclipboard.py; given the plugin-first contribution guidance, please flag a preferred supported seam before landing if this belongs elsewhere. The goal is one shared policy, not another frontend-specific workaround.#911 fixes image-path resolution in the same file-loading module; this patch changes its dimension limit/encoding path, not path lookup. It does not depend on that PR or any MCP lifecycle work.
Validation
Base:
1d25d696; Linux / Python 3.13.13 with the unchanged upstream lock. Tests use actual Pillow-generated images, disposable HOME/XDG, no inherited credentials and blocked socket connect/DNS/bind. Browser capture and clipboard acquisition are mocked; payload processing and file-loader calls are real.python -m pytest -q -o addopts= tests/test_model_image_dimensions.py tests/test_image_utils.py tests/command_line tests/test_command_line_attachments.py tests/tools: 1654 passed, 1 skipped, 1 warning.The skip requires a case-insensitive filesystem. The browser-control unawaited-coroutine warning reproduces on the unpatched base; it was not suppressed.
Compatibility and limits
The conservative 2000px policy reduces detail for images previously allowed above that size. Saved files are not resized, and this does not rewrite images already persisted in conversation history. The existing byte-budget estimate is not a hard encoded-byte guarantee. No universal provider acceptance, live browser/clipboard capture, or live-provider qualification is claimed. No dependency or package-version changes.
The base currently fails the unrelated tilde-completion assertion corrected separately in #916. This PR does not bundle that change or claim full upstream CI is green.