Skip to content

fix(agents): normalize openai-codex base URLs to /backend-api/codex#41347

Closed
pascalkienast wants to merge 3 commits intoopenclaw:mainfrom
pascalkienast:fix/openai-codex-41282
Closed

fix(agents): normalize openai-codex base URLs to /backend-api/codex#41347
pascalkienast wants to merge 3 commits intoopenclaw:mainfrom
pascalkienast:fix/openai-codex-41282

Conversation

@pascalkienast
Copy link
Copy Markdown

Summary

Fixes the remaining openai-codex base URL normalization drift behind #41282.

Some shared openai-codex runtime/model synthesis paths still allowed https://chatgpt.com/backend-api to survive, which meant resolved openai-codex models could still target the non-Codex path instead of the Codex-specific backend.

This patch normalizes those paths to:

  • https://chatgpt.com/backend-api/codex

It also teaches the embedded runner normalization layer to treat legacy /backend-api, /backend-api/codex, and /backend-api/codex/responses inputs as Codex-compatible values that should normalize back to the Codex base URL.

Closes #41282.
Related: #38706, #38736.

Changes

  • update shared OPENAI_CODEX_BASE_URL defaults to /backend-api/codex
  • normalize legacy Codex base URLs in the embedded runner
  • update forward-compat / model / provider expectations
  • add regression coverage for legacy base URL normalization

Testing

corepack pnpm vitest run \
  src/agents/pi-embedded-runner/model.test.ts \
  src/agents/models-config.providers.openai-codex.test.ts \
  src/agents/model-compat.test.ts \
  src/agents/models-config.providers.matrix.test.ts \
  src/commands/models/list.list-command.forward-compat.test.ts \
  src/config/config.secrets-schema.test.ts

Result: 6 test files passed, 93 tests passed.

AI assistance

AI-assisted: yes (Codex was used for the initial patch and test updates).
Reviewed and validated locally before opening this PR.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations agents Agent runtime and tooling size: S labels Mar 9, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e435e782fb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/pi-embedded-runner/model.provider-normalization.ts Outdated
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 9, 2026

Greptile Summary

This PR completes the openai-codex base URL normalization work started in #41282 by updating the canonical OPENAI_CODEX_BASE_URL constant to https://chatgpt.com/backend-api/codex in all remaining locations and adding a dedicated normalization layer in the embedded runner that maps legacy /backend-api, current /backend-api/codex, and the full /backend-api/codex/responses variants back to the canonical codex URL.

Key changes:

  • OPENAI_CODEX_BASE_URL updated from backend-apibackend-api/codex in both models-config.providers.static.ts and pi-embedded-runner/model.provider-normalization.ts
  • model-forward-compat.ts fallback synthesis path aligned to the new URL
  • model.provider-normalization.ts introduces isLegacyOpenAICodexBaseUrl, isOpenAICodexBaseUrl, isOpenAICodexResponsesUrl, and normalizeOpenAICodexBaseUrl — all clean, well-scoped helper functions
  • normalizeOpenAICodexTransport correctly applies normalizeOpenAICodexBaseUrl only when the API is being switched to openai-codex-responses, preserving passthrough for non-codex APIs and custom endpoints
  • All test expectations updated consistently and a dedicated regression test added for the legacy backend-apibackend-api/codex normalization path

Confidence Score: 5/5

  • This PR is safe to merge — it is a targeted, narrowly-scoped URL string normalization with full test coverage and no behavioral regressions for non-Codex providers or custom base URLs.
  • All changes are confined to string constants and URL matching helpers. The normalization function preserves custom (non-matching) base URLs unchanged, correctly handles the no-URL case via fallback, and the guard nextApi === "openai-codex-responses" ensures the rewrite never applies to non-codex API paths. 93 tests pass across 6 test files, including a new regression test specifically for the legacy URL case described in the PR.
  • No files require special attention

Last reviewed commit: 4f5bc7b

Copy link
Copy Markdown
Contributor

Closing as superseded by #69336, landed on main as 8a2d7f2541e00879b3b9e4c712842cf49f1125a8.

The landed fix updates the built-in OpenAI Codex base URL to /backend-api/codex and keeps legacy forms recognized for compatibility, covering the core behavior from this PR. Thanks @pascalkienast.

@steipete steipete closed this Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Regression/incomplete fix: openai-codex still times out on GPT-5.4 after #38736 due to remaining non-codex transport path

3 participants