Skip to content

fix(openai-codex): default undefined model.api to openai-codex-responses - #66969

Closed
saamuelng601-pixel wants to merge 1 commit into
openclaw:mainfrom
saamuelng601-pixel:fix/openai-codex-api-normalize-fallback
Closed

saamuelng601-pixel wants to merge 1 commit into
openclaw:mainfrom
saamuelng601-pixel:fix/openai-codex-api-normalize-fallback

Conversation

@saamuelng601-pixel

Copy link
Copy Markdown
Contributor

Summary

  • normalizeCodexTransport() only converts model.api to openai-codex-responses when the source value is literally "openai-responses"; an undefined / unset model.api falls through to the default /chat/completions endpoint.
  • Cloudflare began issuing managed challenges (403) on /backend-api/codex/chat/completions on 2026-04-14, breaking every openai-codex request that did not explicitly set api: "openai-responses" in user config.
  • The regression appears to have been introduced in commit b90d4ea3d7 ("fix(codex): canonicalize the gpt-5.4-codex alias"), between 2026.4.11 and 2026.4.14 releases.
  • Fix: widen the conversion to also handle !model.api, so the default path ships requests to /responses (which CF is not blocking yet) without requiring user-side workarounds.

Closes the need for the openai-codex-responses override stanza documented in #66633.

Test plan

  • Unit: existing codex provider tests cover api normalization (add case for undefined model.api)
  • Integration: run gpt-5.4 turn with default user config (no openai-codex override) — request should hit /responses, not /chat/completions
  • Regression: verify that an explicit model.api (e.g., "openai") is still preserved as-is

Related: #66633, #62142, #62087

🤖 Generated with Claude Code

normalizeCodexTransport() only converted model.api from "openai-responses"
to "openai-codex-responses" when the codex transport was in use, leaving
undefined/unset api values to fall through to the default
`/chat/completions` endpoint. Cloudflare began issuing managed challenges
(403) on that endpoint on 2026-04-14, breaking every openai-codex
request that did not explicitly set `api: "openai-responses"` in user
config.

Widen the condition to also convert when `model.api` is undefined, so
the default case ships the request to `/responses` (which CF is not
blocking). Users previously working around this by adding explicit
`api: "openai-codex-responses"` stanzas in openclaw.json no longer need
the override.

Refs: openclaw#66633, openclaw#62142, openclaw#62087.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@greptile-apps

greptile-apps Bot commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR widens the api normalization condition in normalizeCodexTransport() so that an undefined model.api also maps to "openai-codex-responses", routing requests to the /responses endpoint instead of the /chat/completions endpoint that Cloudflare started blocking on 2026-04-14. The early-return identity check, the baseUrl resolution that follows, and the handling of explicitly-set model.api values are all unaffected by the change.

Confidence Score: 5/5

Safe to merge — the change is a minimal, well-scoped condition widening with no side-effects on explicit api values or non-Codex base URLs.

Single-condition change, logic is correct, early-return and baseUrl derivation remain sound. Only remaining gap is the missing test from the PR's own test plan, which is P2.

extensions/openai/openai-codex-provider.test.ts — add a case for normalizeResolvedModel with api: undefined

Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/openai/openai-codex-provider.ts
Line: 112-115

Comment:
**Missing test case for the new `undefined` api branch**

The PR description calls out adding a unit case for `undefined model.api`, but `openai-codex-provider.test.ts` only exercises the existing `api: "openai-codex-responses"` path in `normalizeResolvedModel`. A test with `api: undefined` would pin the regression and guard the early-return bypass introduced here.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(openai-codex): default undefined mod..." | Re-trigger Greptile

Comment on lines 112 to +115
const api =
useCodexTransport && model.api === "openai-responses" ? "openai-codex-responses" : model.api;
useCodexTransport && (!model.api || model.api === "openai-responses")
? "openai-codex-responses"
: model.api;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Missing test case for the new undefined api branch

The PR description calls out adding a unit case for undefined model.api, but openai-codex-provider.test.ts only exercises the existing api: "openai-codex-responses" path in normalizeResolvedModel. A test with api: undefined would pin the regression and guard the early-return bypass introduced here.

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/openai/openai-codex-provider.ts
Line: 112-115

Comment:
**Missing test case for the new `undefined` api branch**

The PR description calls out adding a unit case for `undefined model.api`, but `openai-codex-provider.test.ts` only exercises the existing `api: "openai-codex-responses"` path in `normalizeResolvedModel`. A test with `api: undefined` would pin the regression and guard the early-return bypass introduced here.

How can I resolve this? If you propose a fix, please make it concise.

@ngutman

ngutman commented Apr 16, 2026

Copy link
Copy Markdown
Member

Thanks for the original fix work here — this was helpful in narrowing down the Codex transport regression.

We ended up landing the consolidated follow-up in #67635, which merged the missing-api fix with the stale /backend-api/v1 normalization path so both failure modes are covered together.

Also credited you in the merged PR / merge commit. Thank you again.

@ngutman ngutman closed this Apr 16, 2026
ayteks pushed a commit to ayteks/openclaw that referenced this pull request Apr 16, 2026
…nd discovery (openclaw#67635)

Merged via squash.

Supersedes:
- openclaw#66969 by @saamuelng601-pixel
- openclaw#67159 by @hclsys

Co-authored-by: saamuelng601-pixel <[email protected]>
Co-authored-by: hclsys <[email protected]>
xudaiyanzi pushed a commit to xudaiyanzi/openclaw that referenced this pull request Apr 17, 2026
…nd discovery (openclaw#67635)

Merged via squash.

Supersedes:
- openclaw#66969 by @saamuelng601-pixel
- openclaw#67159 by @hclsys

Co-authored-by: saamuelng601-pixel <[email protected]>
Co-authored-by: hclsys <[email protected]>
kvnkho pushed a commit to kvnkho/openclaw that referenced this pull request Apr 17, 2026
…nd discovery (openclaw#67635)

Merged via squash.

Supersedes:
- openclaw#66969 by @saamuelng601-pixel
- openclaw#67159 by @hclsys

Co-authored-by: saamuelng601-pixel <[email protected]>
Co-authored-by: hclsys <[email protected]>
Mquarmoc pushed a commit to Mquarmoc/openclaw that referenced this pull request Apr 20, 2026
…nd discovery (openclaw#67635)

Merged via squash.

Supersedes:
- openclaw#66969 by @saamuelng601-pixel
- openclaw#67159 by @hclsys

Co-authored-by: saamuelng601-pixel <[email protected]>
Co-authored-by: hclsys <[email protected]>
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…nd discovery (openclaw#67635)

Merged via squash.

Supersedes:
- openclaw#66969 by @saamuelng601-pixel
- openclaw#67159 by @hclsys

Co-authored-by: saamuelng601-pixel <[email protected]>
Co-authored-by: hclsys <[email protected]>
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…nd discovery (openclaw#67635)

Merged via squash.

Supersedes:
- openclaw#66969 by @saamuelng601-pixel
- openclaw#67159 by @hclsys

Co-authored-by: saamuelng601-pixel <[email protected]>
Co-authored-by: hclsys <[email protected]>
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request May 13, 2026
…nd discovery (openclaw#67635)

Merged via squash.

Supersedes:
- openclaw#66969 by @saamuelng601-pixel
- openclaw#67159 by @hclsys

Co-authored-by: saamuelng601-pixel <[email protected]>
Co-authored-by: hclsys <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…nd discovery (openclaw#67635)

Merged via squash.

Supersedes:
- openclaw#66969 by @saamuelng601-pixel
- openclaw#67159 by @hclsys

Co-authored-by: saamuelng601-pixel <[email protected]>
Co-authored-by: hclsys <[email protected]>
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
…nd discovery (openclaw#67635)

Merged via squash.

Supersedes:
- openclaw#66969 by @saamuelng601-pixel
- openclaw#67159 by @hclsys

Co-authored-by: saamuelng601-pixel <[email protected]>
Co-authored-by: hclsys <[email protected]>
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
…nd discovery (openclaw#67635)

Merged via squash.

Supersedes:
- openclaw#66969 by @saamuelng601-pixel
- openclaw#67159 by @hclsys

Co-authored-by: saamuelng601-pixel <[email protected]>
Co-authored-by: hclsys <[email protected]>
Heetisk pushed a commit to Heetisk/openclaw that referenced this pull request Sep 28, 2026
…nd discovery (openclaw#67635)

Merged via squash.

Supersedes:
- openclaw#66969 by @saamuelng601-pixel
- openclaw#67159 by @hclsys

Co-authored-by: saamuelng601-pixel <[email protected]>
Co-authored-by: hclsys <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants