Skip to content

fix(codex): sanitize kwargs for gpt-5.5 on Codex backend#29740

Open
LifeJiggy wants to merge 2 commits into
NousResearch:mainfrom
LifeJiggy:fix/codex-gpt5-kwarg-sanitize
Open

fix(codex): sanitize kwargs for gpt-5.5 on Codex backend#29740
LifeJiggy wants to merge 2 commits into
NousResearch:mainfrom
LifeJiggy:fix/codex-gpt5-kwarg-sanitize

Conversation

@LifeJiggy

Copy link
Copy Markdown
Contributor

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.

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent loop, run_agent.py, prompt builder provider/openai OpenAI / Codex Responses API P2 Medium — degraded but workaround exists labels May 21, 2026
@LifeJiggy

Copy link
Copy Markdown
Contributor Author

@teknium1 PTAL

LifeJiggy added 2 commits June 9, 2026 09:28
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
@LifeJiggy LifeJiggy force-pushed the fix/codex-gpt5-kwarg-sanitize branch from f51a91d to 7e222d6 Compare June 9, 2026 08:36
@LifeJiggy

Copy link
Copy Markdown
Contributor Author

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.

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

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists provider/openai OpenAI / Codex Responses API type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants