Skip to content

fix(openai): stop mapping params(top_k=) to top_logprobs - #424

Merged
cpsievert merged 5 commits into
mainfrom
fix-openai-top-k
Sep 21, 2026
Merged

cpsievert merged 5 commits into
mainfrom
fix-openai-top-k

Conversation

@cpsievert

Copy link
Copy Markdown
Collaborator

Closes #412.

OpenAIProvider.translate_model_params() mapped the standardized top_k sampling parameter onto OpenAI's top_logprobs field, which controls how many log-probabilities are returned per token — an unrelated setting. Since OpenAI's API has no top_k sampling parameter, top_k is removed from supported_model_params() and is now dropped with the standard unsupported-parameter warning, matching ellmer's resolution (tidyverse/ellmer#1115).

OpenAICompletionsProvider never had the mapping; subclasses of the Responses provider (OpenAIAzureProvider, BedrockResponsesProvider) inherit the fix. No VCR cassettes needed re-recording (top_logprobs only appears in response payloads). Adds a regression test asserting top_k is not translated.

top_k (sampling) and top_logprobs (response metadata) are unrelated,
and OpenAI's API has no top_k sampling parameter. top_k is no longer
in supported_model_params(), so it's dropped with the standard
unsupported-parameter warning. Matches ellmer's fix
(tidyverse/ellmer#1115).

Closes #412

This comment was marked as resolved.

cpsievert and others added 4 commits September 21, 2026 09:53
The test module aliases ChatOpenAICompletions as ChatOpenAI, so the
regression test targeted the Completions provider, which never had the
top_k -> top_logprobs mapping. Use a local import of the Responses-API
ChatOpenAI so the test actually exercises the fix, and assert top_k is
absent from supported_model_params().
@cpsievert
cpsievert merged commit ee7da2f into main Sep 21, 2026
7 checks passed
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.

OpenAI provider incorrectly maps params(top_k=) to top_logprobs

2 participants