Skip to content

fix(codex): stop overriding chatgpt_base_url so ChatGPT workspace discovery works - #697

Merged
lis186 merged 2 commits into
mainfrom
fix/codex-chatgpt-routing
Oct 17, 2026
Merged

lis186 merged 2 commits into
mainfrom
fix/codex-chatgpt-routing

Conversation

@lis186

@lis186 lis186 commented Oct 17, 2026

Copy link
Copy Markdown
Owner

Fixes #671.

Problem

ChatGPT-login Codex (0.159.2, 0.163.0) aborted at startup through ccxray: account/read failed during TUI bootstrap: workspace routing discovery failed (-32603). The launcher overrode both openai_base_url and chatgpt_base_url with http://localhost:<port>/v1. Codex runs workspace discovery against chatgpt_base_url, which then hit a wrong upstream path (404), and Codex also requires an HTTPS chatgpt_base_url.

Fix

  • In ChatGPT-OAuth mode, ccxray codex and the herdr plugin now pass only -c openai_base_url=<proxy>/v1. chatgpt_base_url keeps Codex's default (https://chatgpt.com/backend-api/), so account and discovery calls go straight to chatgpt.com over HTTPS. Model traffic (/responses, HTTP and WebSocket) still goes through ccxray and is recorded.
  • Invariant, now pinned by tests: the proxy base URL ends in /v1, never in /backend-api/codex. Codex applies a discovered workspace origin to the openai provider only when supports_codex_backend_routes() holds (base_url unset or ending in /backend-api/codex), so model traffic cannot be re-routed past the proxy.
  • ccxray codex prints a read-only warning when $CODEX_HOME/config.toml sets chatgpt_base_url to a loopback address (the setup in the issue). It never edits the file.
  • The API-key path is unchanged.
  • Docs: docs/codex-workspace-routing.md is rewritten to describe the resolved state, including the residency caveat (CHATGPT_BASE_URL covers the origin only; us/us_cr workspaces may still be rejected upstream). Also updated: env-vars, provider-modules, running-ccxray, wire-protocol-reference (obs-fragile, Codex 0.159.2–0.163.0), the openspec spec, and the CHANGELOG (moved from Known limitations to Fixed).

Verification

  • Fail-on-old: the new absence and /v1 assertions fail on 3bfb426 and pass with this patch.
  • Targeted tests: providers, auth-launcher, startup and herdr-plugin, 385/387 passing. The 1 failure is the box-local "Herdr Node launcher fallback", which also fails on main; the other test is skipped (macOS-only). Unit lane: 2045/2045.
  • Real run on Linux with Codex 0.163.0 and ChatGPT login, using an isolated CCXRAY_HOME and a free port: ccxray codex -m gpt-6-luna started without -32603 and completed one prompt. Two entries were recorded (the turn plus title generation), with the correct cwd and exact cost. The test captures were deleted afterwards.
  • Plan and diff were reviewed independently.

…covery works (#671)

In ChatGPT-OAuth mode the Codex launcher (server/providers.js) and the
Herdr plugin (codexAgentArgs) now set only openai_base_url=<proxy>/v1.
Codex keeps its default chatgpt_base_url, so workspace discovery and
account/plugin/connector calls go to chatgpt.com over HTTPS instead of
failing with -32603 on a plaintext loopback URL. Model traffic still
reaches ccxray; API-key mode is unchanged.

The /v1 suffix is load-bearing: Codex re-routes the openai provider to a
discovered workspace origin only when its base_url ends in
/backend-api/codex. Tests pin the suffix and the absence of
chatgpt_base_url in both launchers, plus argv parity between them.

ccxray codex now warns, read-only, when $CODEX_HOME/config.toml still
points chatgpt_base_url at a loopback proxy, which keeps failing.

Docs: rewrite codex-workspace-routing.md to the resolved state (gate
invariant, broken entry points, residency/us caveat, user-config note),
update env-vars, provider-modules, running-ccxray, wire-protocol rows,
openspec two-domain-auth scenario, and move the CHANGELOG entry from
Known limitations to Fixed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T12:51:52.735430Z f33ee6d PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: f33ee6dffc

ℹ️ 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 server/providers.js Outdated
Comment on lines +57 to +58
console.warn(`[ccxray] chatgpt_base_url in ${codexConfigPath(env)} points at a loopback proxy (${url}); `
+ 'Codex ChatGPT workspace discovery will fail (#671). Remove it — ccxray no longer needs it.');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Redact secrets from the loopback URL warning

When chatgpt_base_url includes URL userinfo, a query token, or another credential (for example, an authenticated local proxy), interpolating the complete value copies that secret into stderr and potentially captured launch logs. The warning only needs the host and port to identify the stale loopback setting, so redact credentials and query/fragment data before printing it.

Useful? React with 👍 / 👎.

@lis186
lis186 merged commit a22b496 into main Oct 17, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(codex): Codex fails TUI bootstrap through proxy — "workspace routing discovery failed (-32603)"

1 participant