Repository navigation
Conversation
Greptile SummaryThis PR fixes a regression where users who had Confidence Score: 5/5Safe to merge — minimal two-line logic change with correct regex, good test coverage, and no regressions to existing paths. All findings are P2 or lower. The regex change is narrowly scoped and correctly anchored. The baseUrl-rewrite condition change closes a pre-existing asymmetry with useCodexTransport. The no-op short-circuit for the canonical URL is preserved by value-equality. Tests cover the new paths and negative guards. No files require special attention. Reviews (1): Last reviewed commit: "fix(openai-codex): normalize stale /back..." | Re-trigger Greptile |
Older OpenClaw releases persisted `https://chatgpt.com/backend-api/v1` as the Codex provider's baseUrl in agent-scoped `~/.openclaw/agents/main/agent/models.json`. The Codex responses endpoint is `/backend-api/codex/responses`; requests to `/backend-api/v1/codex/responses` are mitigated by Cloudflare with a 403 challenge (`cf-mitigated: challenge`), which OpenClaw surfaces as misleading downstream errors (DNS lookup failure, rate-limit style). `openclaw#66969` fixed the `model.api === undefined` regression, but a stale `/v1` baseUrl survives that fix because `normalizeCodexTransport` only rewrites baseUrl when `!model.baseUrl || isOpenAIApiBaseUrl` matches — and the stale `/v1` variant matches neither. Fix: - Extend `isOpenAICodexBaseUrl` to accept both the canonical `/backend-api` and the legacy `/backend-api/v1` form (and their trailing-slash variants). - In `normalizeCodexTransport`, rewrite baseUrl to the canonical `OPENAI_CODEX_BASE_URL` when the stored value matches either form, so the stale `/v1` value is healed on the next model resolve. Behavior preserved for: - canonical `/backend-api` baseUrl: rewrite is a no-op (returned model is reference-equal to the input when no fields change). - unrelated paths (`/backend-api/v2`, `/backend-api/codex`, `/api`, arbitrary proxies): still rejected. - non-openai-codex providers: unaffected. Fixes openclaw#67131
This comment was marked as low quality.
This comment was marked as low quality.
…nd discovery (#67635) Merged via squash. Supersedes: - #66969 by @saamuelng601-pixel - #67159 by @hclsys Co-authored-by: saamuelng601-pixel <[email protected]> Co-authored-by: hclsys <[email protected]>
|
Thanks for the original fix work here — this was helpful in pinning down the stale Codex We ended up landing the consolidated follow-up in #67635, which merged this fix together with the related missing- Also credited you in the merged PR / merge commit. Thank you again. |
…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]>
…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]>
…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]>
…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]>
…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]>
…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]>
…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]>
…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]>
…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]>
…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]>
…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]>
What
Two-line logic change plus tests:
extensions/openai/base-url.ts—isOpenAICodexBaseUrlregex now matches bothhttps://chatgpt.com/backend-apiand the legacyhttps://chatgpt.com/backend-api/v1:extensions/openai/openai-codex-provider.ts—normalizeCodexTransportnow includesisOpenAICodexBaseUrl(model.baseUrl)in the baseUrl-rewrite condition, so the widened matcher rewrites legacy values to the canonical root:Why
Fixes #67131.
Older OpenClaw releases persisted
https://chatgpt.com/backend-api/v1as the Codex provider's baseUrl in agent-scoped~/.openclaw/agents/main/agent/models.json. The Codex responses endpoint is actually/backend-api/codex/responses; requests to/backend-api/v1/codex/responsesget Cloudflare-blocked withHTTP 403 + cf-mitigated: challenge, which OpenClaw surfaces as misleading downstream errors (DNS lookup failed, raw HTML challenge, rate-limit style).PR #66969 already landed a partial fix for the related
model.api === undefinedregression, but stale/v1baseUrls survive #66969 becausenormalizeCodexTransportonly rewrites baseUrl when!model.baseUrl || isOpenAIApiBaseUrl(model.baseUrl)— and/backend-api/v1matches neither: it is NOTapi.openai.com/v1(that matcher), and it was NOT previously recognised as a codex URL (this PR adds that).The reporter (#67131) independently confirmed the fix by manually editing the persisted baseUrl to
/backend-api, which restored working codex turns.Relationship to #66969
#66969 is OPEN and touches
normalizeCodexTransportin the same file but fixes a different symptom (apiundefined for users without explicitapi: 'openai-responses'in user config). The two fixes compose cleanly:apiis upgraded toopenai-codex-responseson the codex transport path.baseUrlis canonicalized, including when it was previously persisted with the stale/v1suffix.Neither fix makes the other obsolete; both reach the same
useCodexTransport && model.api === 'openai-responses'code path only under mutually-exclusive conditions.Behavior
""/ undefined/backend-apihttps://api.openai.com/backend-apihttps://api.openai.com/v1/backend-apihttps://chatgpt.com/backend-apihttps://chatgpt.com/backend-api/v1/backend-apihttps://chatgpt.com/backend-api/v2https://chatgpt.com/backend-api/codexTest
Added 4 new test cases:
extensions/openai/base-url.test.ts/backend-api/v1and/backend-api/v1/forms (http + https)/backend-api/v2,/backend-api/codex,/apito guard against over-broadeningextensions/openai/openai-codex-provider.test.ts/backend-api/v1baseUrl to canonical/backend-api, keepsapi: 'openai-codex-responses'/backend-apibaseUrl unchanged (reference-equal short-circuit innormalizeCodexTransport)pnpm test -- extensions/openai/base-url.test.tscurrently fails on an unrelated pre-existing infra bug (test/non-isolated-runner.ts→Class extends value undefined) that reproduces onmainwith no edits. Regex logic independently verified against 10 URL variants via isolatednode -e.Risk
Low. Single regex widening + one additional clause in an existing rewrite condition. Canonical and unrelated-path cases preserved. The only behavior change is that stale
/backend-api/v1values — which today cause 403s and misleading errors — get healed on the next model resolve.