Repository navigation
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Author
|
This one needed a rebase after some time on the back burner; it applied cleanly. The underlying issue is unchanged: main still sends both max_tokens and max_completion_tokens for vision models. |
wgnrai
force-pushed
the
fix/vision-max-tokens-collision
branch
from
September 23, 2026 04:41
bbc2dbf to
663ebe5
Compare
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
Setting
max_completion_tokensin a vision preset's kwargs breaks everyvision_loadcall with:The cause is in
build_vision_model()(plugins/_model_config/helpers/model_config.py). It always injectsmax_tokens, either from the preset or the default of 2000, into the model kwargs. When the preset also setsmax_completion_tokensunder kwargs, both parameters end up in the same request and the provider rejects it.The Responses API path already handles this collision (helpers/litellm_transport.py pops both and maps them to
max_output_tokens), but the vision side-car builds its call throughunified_calland never goes through that normalization.Fix
Skip the
max_tokensinjection inbuild_vision_model()whenmax_completion_tokensis already present in the merged kwargs. Preset intent wins, which matches the precedence used on the Responses path.Testing
Added
plugins/_model_config/tests/test_build_vision_model_max_tokens.pywith four cases:max_completion_tokensanywhere:max_tokensstill injected (default behavior unchanged)max_completion_tokensin kwargs:max_tokensnot injected (the bug)max_tokens=4096with no collision: injected as 4096max_tokensand kwargsmax_completion_tokensboth set: onlymax_completion_tokenssurvivesAll four pass with
python -m pytest plugins/_model_config/tests/test_build_vision_model_max_tokens.py -v.Also confirmed on a live instance: with the patch,
vision_loadsucceeds again where it previously returned the BadRequestError above.