Skip to content

fix: use max_completion_tokens for OpenAI connection tests and fix parameter error classification - #46

Merged
kccarlos merged 4 commits into
mainfrom
fix/openai-connection-and-sampling
Nov 15, 2026
Merged

kccarlos merged 4 commits into
mainfrom
fix/openai-connection-and-sampling

Conversation

@kccarlos

Copy link
Copy Markdown
Owner

Summary

  • OpenAI connection test (buildConnectionTest): Send max_completion_tokens: 16 instead of max_tokens: 1 when testing openai (/v1/chat/completions), since OpenAI deprecated max_tokens and rejects it with HTTP 400 (Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.) on reasoning and newer GPT-5+/GPT-6+ models (o1, o3, o4-mini, gpt-5*, gpt-6*).
  • Connection failure classification (classifyConnectionFailure): Do not classify HTTP 400/422 parameter, capability, or context-length errors that mention "with this model" / "for this model" (or have error.code unsupported_parameter / unsupported_value or error.param !== 'model') as providerSetup.modelUnknown (field: 'model'). Genuine unknown/invalid model errors (status === 404, code === 'model_not_found', param === 'model', "model: ...", "not a valid model ID", etc.) still highlight the model field.
  • Sampling options (samplingOptions): Omit temperature for OpenAI reasoning and fixed-temperature models (o1*, o3*, o4*, codex*, gpt-4o*-search-preview*, and gpt-5* / gpt-6*+ except gpt-*-chat*, both direct and openai/... on OpenRouter) so OpenRouter requests do not send unsupported temperature values to OpenAI reasoning models and @ai-sdk/openai does not emit unsupported-temperature warnings on every call.
  • Token-limit error detection (isTokenLimitError): Exclude unsupported_parameter / unsupported_value messages from TOKEN_LIMIT_PATTERN so an error mentioning 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead. never triggers hierarchical summarization or content-truncation retries.

Testing

  • pnpm check
  • pnpm test (653/653 passing)
  • node tools/ui/flows.mjs --theme=light --only=popup-setup,popup-setup-models,popup-setup-models-failure,settings-model-missing

@kccarlos
kccarlos merged commit 0e394e3 into main Nov 15, 2026
5 of 6 checks passed
@kccarlos
kccarlos deleted the fix/openai-connection-and-sampling branch November 15, 2026 10:00
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