Skip to content

fix(model_config): do not default max_tokens when vision preset uses max_completion_tokens - #1856

Open
wgnrai wants to merge 1 commit into
agent0ai:mainfrom
wgnrai:fix/vision-model-token-collision
Open

wgnrai wants to merge 1 commit into
agent0ai:mainfrom
wgnrai:fix/vision-model-token-collision

Conversation

@wgnrai

@wgnrai wgnrai commented Aug 28, 2026

Copy link
Copy Markdown

Problem

With a Vision Model preset whose kwargs include max_completion_tokens (as the v2.11 preset UI saves for OpenAI-style models), every vision-model call fails with:

litellm.BadRequestError: Setting 'max_tokens' and 'max_completion_tokens' at the same time is not supported.

The native vision_load delegation path is broken for these presets.

Root cause

build_vision_model() unconditionally setdefaults max_tokens on top of preset kwargs that already carry max_completion_tokens; both keys reach the provider.

Fix

Default whichever token key the preset already uses (max_completion_tokens when present, else max_tokens). No behavior change for presets without max_completion_tokens.

Test

test_vision_model_does_not_duplicate_token_params — asserts the built vision model kwargs carry exactly one token key when the preset uses max_completion_tokens.

…max_completion_tokens

Presets saved by the v2.11 preset UI can carry max_completion_tokens in the Vision Model slot kwargs (OpenAI-style models). build_vision_model() unconditionally setdefault-ed max_tokens on top of those kwargs, so every litellm call carried both token keys and OpenAI rejected the request with: BadRequestError: Setting 'max_tokens' and 'max_completion_tokens' at the same time is not supported. This broke the native vision_load delegation path for such presets.

Default whichever token key the preset already uses: max_completion_tokens when present, else max_tokens. No behavior change for presets without max_completion_tokens.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant