fix(codex): sanitize kwargs for gpt-5.5 on Codex backend#29740
fix(codex): sanitize kwargs for gpt-5.5 on Codex backend#29740LifeJiggy wants to merge 2 commits into
Conversation
|
@teknium1 PTAL |
GPT-5.5 / codex-gpt-5.5 on the Codex backend rejects requests that include 'reasoning', 'include', or 'store' kwargs with HTTP 400, since these are Responses API parameters not supported by the older completions-compatible Codex surface. Strip these fields post-hoc when the model name starts with 'gpt-5.5' or 'codex-gpt-5.5' on the codex backend, preserving them for all other models. Fixes NousResearch#21444
f51a91d to
7e222d6
Compare
|
Hardenings applied (commit 7e222d6): P1 fix — false-positive prefix match: model.startswith("gpt-5.5") incorrectly matched gpt-5.50 (string "gpt-5.50" starts with "gpt-5.5"). Fixed with exact match or separator-bounded prefix (startswith(p+"-") / startswith(p+".")). Enhancement 1 — Module-level constants: Extracted _CODEX_KWARG_STRIP_KEYS and _CODEX_STRIP_MODEL_PREFIXES as single source of truth for both stripping logic and tests. Enhancement 2 — Debug logging: Added logger.debug() when kwargs are stripped, so operators can see exactly which keys were removed and for which model. Enhancement 3 — Case-insensitive matching: GPT-5.5, Codex-GPT-5.5 (uppercase/mixed case) now handled via model.lower(). 12 tests added covering: basic stripping of reasoning/include/store, case insensitivity, non-codex backend preservation, non-affected models (gpt-5.4), partial prefix false positive (gpt-5.50), request_overrides injection, key-absent safety, and constant validation. All 63 tests in test_codex_transport.py pass. |
Title: fix(codex): sanitize kwargs for gpt-5.5 on Codex backend
Description:
GPT-5.5 / codex-gpt-5.5 on the Codex backend rejects requests that include reasoning, include, or store kwargs with HTTP 400, since these are Responses API parameters not supported by the older completions-compatible Codex surface.
Added a post-hoc sanitization step in ResponsesApiTransport.build_kwargs() that strips reasoning, include, and store when the model name starts with gpt-5.5 or codex-gpt-5.5 on the codex backend. All other models (gpt-4o, xAI, GitHub) are unaffected.
39 codex transport tests pass.