Skip to content

Serve the ChatGPT subscription relay to the Codex app - #1342

Open
andy-xu-db wants to merge 2 commits into
stack/codex-relay-clifrom
stack/codex-relay-desktop
Open

andy-xu-db wants to merge 2 commits into
stack/codex-relay-clifrom
stack/codex-relay-desktop

Conversation

@andy-xu-db

@andy-xu-db andy-xu-db commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

🥞 Stacked PR

Use this link to review incremental changes.


Summary

The Codex app now gets ChatGPT subscription relay too, configured by the same ug configure / ug codex --provider <relayed mps> run as the CLI. The app has no per-session ug process and can't combine a token helper with its ChatGPT login, so ug's per-user login service (the existing Codex desktop OTLP proxy service: systemd user unit, LaunchAgent or scheduled task) also serves the Codex relay proxy on a stable loopback port.

  • ug otel-proxy gains --relay-port, which starts start_relay_proxy(..., codex=True) in the same process. The unit carries the relay port, which is recorded once and recovered on later runs, like the OTLP port.
  • ~/.codex/config.toml (Codex app settings) gets model_provider = "Databricks" and a relayed provider block. The block points at http://127.0.0.1:<relay port>/v1, sets requires_openai_auth with no auth command, and persists the Databricks-Model-Provider-Service header, because the app can't pick a provider service at launch (same as the Claude Desktop profile). ug codex sessions still use their own -c provider and per-session proxy, which outrank this file.
  • A user-defined provider in that file is left alone, with a warning. Switching back to a non-relayed provider, or ug revert, removes only ug's own block (identified by the recorded relay port), and removes the service unless tracing still needs it.
  • Setup problems only warn, as desktop tracing does, and dry-run writes nothing. After setup, ug says to restart the app and sign in with ChatGPT.
  • Side effect, noted in the README: with a relayed provider configured, plain codex also uses the app's relay entry.

Testing

  • New tests in tests/test_agent_codex.py (relay lifecycle with stable ports across reconfigures, tracing and relay sharing one unit, partial removal and revert, user provider preserved, dry-run, and launchd/schtasks argv) and tests/test_cli.py (otel-proxy --relay-port).
  • Same six-file pytest run as the previous PR: 1931 passed. just lint clean.
  • Service managers are mocked. Not yet validated against the real Codex app, systemd, launchd or Task Scheduler.

This pull request and its description were written by Isaac.

@andy-xu-db
andy-xu-db marked this pull request as ready for review October 28, 2026 20:24
@andy-xu-db
andy-xu-db force-pushed the stack/codex-relay-desktop branch from 761ce60 to 2f23451 Compare October 29, 2026 20:13
andy-xu-db and others added 2 commits October 29, 2026 22:09
For a relayed OpenAI provider, ug's per-user login service (the Codex desktop OTLP proxy
service) also runs the Codex relay proxy on a stable loopback port, and ~/.codex/config.toml
points the Codex app's Databricks provider at it with requires_openai_auth and the MPS header.
Codex's own ChatGPT login supplies Authorization. Only ug's own block is removed on
switch-back or revert; a user-defined provider is left alone with a warning.

Co-authored-by: Isaac <no-reply@databricks.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@andy-xu-db
andy-xu-db force-pushed the stack/codex-relay-desktop branch from 2f23451 to ce04d8f Compare October 29, 2026 22:12
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.

1 participant