fix(models): report Responses-only settings dropped by Chat Completions - #4838
fix(models): report Responses-only settings dropped by Chat Completions#4838ConnorMoss02 wants to merge 2 commits into
Conversation
ModelSettings.truncation, response_include and context_management are read only by OpenAIResponsesModel, at openai_responses.py:1012, :958 and :1026. OpenAIChatCompletionsModel never reads them, so setting one on a Chat Completions model did nothing and said nothing. Handle them the way the file already handles an unsupported prompt and unsupported reasoning settings: raise UserError under strict feature validation, otherwise warn once and carry on. Callers who set none of them are unaffected. Closes openai#4837
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
The single _has_warned_unsupported_response_settings flag suppresses newly introduced unsupported settings too. If the first call only uses truncation and a later call adds context_management, that later setting is silently dropped. Please track which setting names have been warned and add a staggered-settings regression.
A single flag suppressed the warning for a setting introduced on a later call: the first call warning about truncation silenced a second call that added context_management, dropping it without a word. That is the behavior this handler exists to report. Track the setting names already warned about and name only the new ones, so nothing is dropped in silence and a repeated setting stays quiet.
|
Reproduced it:
Fixed in a58dabf by tracking the setting names already warned about instead of a single flag. Now: Only the newly introduced setting is named, so a repeated setting does not become recurring noise. Strict mode is unchanged and still raises on the full set. Added 864 tests pass. mypy clean on the file, ruff check and format clean. One thing worth flagging separately: |
Closes #4837
Summary
ModelSettings.truncation,response_includeandcontext_managementare read only byOpenAIResponsesModel.OpenAIChatCompletionsModelnever reads them, so setting one on a Chat Completions model did nothing and said nothing.openai_responses.pyopenai_chatcompletions.pytruncation:1012response_include:958-959context_management:1026The one
truncationmatch inopenai_chatcompletions.pyisraise_on_length_truncationat:494, which is a different thing.Approach
The file already reports two other Responses-only features rather than dropping them,
_handle_unsupported_promptand_handle_unsupported_reasoning_settings. This adds a third handler in the same shape, called from the same place as the reasoning one:UserErrorwhenstrict_feature_validationis on_has_warned_unsupported_response_settingsNo public API change, and nothing about request construction changes.
Tests
tests/models/test_openai_chatcompletions.py, mirroring the existing reasoning-settings pair:UserErrorunder strict validationConfirmed load-bearing: with
openai_chatcompletions.pyreverted, the first two fail.Validation
uv run mypy srcreports the same 46 pre-existing errors inextensions/sandbox/andvoice/before and after this change; none are in the touched file.