Skip to content

feat(providers): add gateway-owned OpenAI Codex subscription OAuth provider #2740

Closed

Description

@saariuslystoned

Problem Statement

OpenShell does not currently provide a first-class way for a NemoClaw/OpenClaw sandbox to use a user's Codex subscription through OpenAI's supported Sign in with ChatGPT flow while keeping the OAuth grant under gateway control.

Official OpenAI documentation says Codex CLI supports signing in with ChatGPT for subscription access through a browser flow: https://learn.chatgpt.com/docs/auth

Today the practical choices are incomplete:

  • sign in inside the sandbox or copy the Codex auth file, exposing usable OAuth material to the sandbox;
  • copy an existing host Codex login into OpenShell, creating two owners of rotating credentials;
  • run a separate host OpenClaw gateway and point OpenShell's compatible-endpoint provider at it;
  • use an API key or a local model instead of the user's Codex subscription.

A current downstream test on NemoClaw v0.0.103, OpenShell 0.0.85, and OpenClaw 2026.7.1-2 reproduced the gap: an openai-codex login initiated from the sandbox was denied at the OpenShell egress boundary before the browser login could complete. No OpenClaw auth profile was created. Local OpenAI-compatible inference remained healthy, so this was an authentication/provider-integration gap rather than a general inference outage.

This is downstream-visible in NVIDIA/NemoClaw#1793. #988 proved that provider-backed Codex placeholders can work, but it did not establish gateway ownership of login, refresh, expiry, or revocation. #1306 provides the generic gateway-owned refresh foundation but does not define the OpenAI/Codex subscription provider, login UX, endpoint policy, or NemoClaw/OpenClaw integration.

Proposed Design

Add a provider profile such as openai-codex-oauth with a user-facing alias such as codex-subscription.

  1. Explicit, provider-owned login

    • A provider creation login option starts an attended OpenAI-supported Codex/ChatGPT browser login.
    • The resulting grant is created specifically for OpenShell and is owned by that provider instance.
    • Do not import or copy a live Codex desktop/CLI refresh token. An existing Codex login must remain independently usable.
  2. Gateway-only credential lifecycle

  3. Sandbox-scoped authorization

    • Resolve the subscription route only for an authenticated sandbox that has this exact provider attached.
    • An unattached sandbox must not receive or use a gateway-wide personal subscription route.
    • Keep provider instances isolated by owner and sandbox attachment.
  4. Endpoint-bound use

    • Pin or strictly allow-list the supported HTTPS OpenAI/Codex origins and required route shapes.
    • Do not honor a generic provider base-URL override for this bearer credential.
    • If OpenAI does not publish a stable third-party integration contract, mark the provider experimental and centralize/version the compatibility boundary rather than spreading private constants through the codebase.
  5. Fail-closed refresh and expiry

    • Refresh persistence must be version-matched and atomic across rotation, deletion, and reconfiguration.
    • Distinguish terminal grant rejection from retryable timeout, rate-limit, and server errors.
    • Enforce credential expiry during route resolution and in supervisor caches; an expired or reauth-required credential must be omitted and previously cached routes cleared.
    • Provide bounded status, re-login, logout, and revocation guidance without exposing credentials.
  6. NemoClaw/OpenClaw UX

    • NemoClaw should be able to attach the provider to an OpenClaw sandbox and select the Codex-backed model without a separately managed host gateway.
    • OpenClaw should complete a normal tool-free response through inference.local, while the subscription credential remains gateway-side.

Acceptance Criteria

  • OpenShell creates a distinct gateway-owned grant; an existing Codex desktop/CLI login continues working before and after OpenShell refresh.
  • No access token, refresh token, account token, or equivalent reusable credential appears in sandbox environment, filesystem, normal CLI output, diagnostics, or logs.
  • Sandbox A with the provider attached can use the route; sandbox B without it is denied.
  • A hostile or custom base URL cannot receive the subscription bearer credential.
  • Refresh, delete-during-refresh, reconfigure-during-refresh, expiry, reauth-required, 408/429, and transient 5xx cases are covered.
  • Expired routes stop resolving even when a supervisor cannot refresh its bundle from the gateway.
  • E2E proof covers provider login, attachment, one OpenClaw response, credential rotation, and logout/revocation behavior.
  • The implementation does not remove unrelated provider-refresh or concurrency regression coverage.

Alternatives Considered

Agent Investigation

Checklist

  • I've reviewed existing issues and the architecture docs
  • This is a design proposal, not a "please build this" request

Activity

  1. saariuslystoned commented on Aug 14, 2026

    @saariuslystoned
    Author

    Public implementation groundwork is staged at https://github.com/saariuslystoned/OpenShell/tree/codex/2740-openai-codex-oauth from upstream main commit c4b500a. I have intentionally not opened an upstream PR yet: this issue is still state:triage-needed, and the contributor account is not yet listed in the repository's vouch file, so the repository contract says a feature PR would be automatically closed. No credentials or live systems were touched. I will keep the first implementation slice bounded to the provider-specific contract on top of #1306 after maintainer disposition.

  2. saariuslystoned commented on Aug 14, 2026

    @saariuslystoned
    Author

    Implementation and proof update for the Codex design

    The Codex and Grok lanes have now been converged onto one provider-neutral, Gateway-owned subscription OAuth foundation in saariuslystoned/OpenShell#1.

    • Exact reviewed head: 2098a95c872c72ddfe36430a8c0f0c1a37b5edfb on immutable upstream base c4b500a7de64d0b66e3ee8098f58d14299092162
    • Codex is a dedicated adapter with attended ChatGPT device authorization, OpenAI exchange/refresh/revoke, account and FedRAMP binding, required headers, pinned origin, and the exact Responses route.
    • A strict tool-free OpenClaw turn through inference.local selected codex-subscription-e2e/gpt-5.6-sol, returned HTTP 200 with the exact expected payload, used no fallback, exposed no checked credential environment variables, and offered zero tools.
    • Codex rotation advanced its own generation; both Codex and the untouched Grok route remained usable. Grok rotation did not alter Codex state; the one bounded Codex retry followed an HTTP-200 upstream SSE server_error and passed immediately with no fallback.
    • Codex logout remotely revoked and locally cleared only the Codex grant. Its OpenClaw and direct routes then failed closed with sanitized HTTP 503 while Grok still passed. Terminal Codex credential/config key count was zero.
    • The live OpenClaw compatibility edge was fixed route-locally: max_output_tokens is removed only for the exact ChatGPT Codex subscription Responses route, while generic API-key Responses routes retain it.
    • Terminal mise run ci passed in 299.32 seconds; the server result was 1,366 passed, 0 failed, 7 pre-existing ignored. Exact-head OpenClaw autoreview completed two passes with TruffleHog clean, 0 accepted/actionable findings, and confidence 0.99.

    Proof: authoritative packet and dual-provider live runtime matrix.

    No host Codex credential was imported or inspected. The task-owned grant was remotely revoked and locally cleared after proof. No merge, deploy, or upstream feature PR has been performed; maintainer triage and contributor-vouch gates remain unchanged.

  3. johntmyers commented on Sep 14, 2026

    @johntmyers
    Collaborator

    Superseded by #3331, which now tracks the shared, workspace-scoped gateway-owned OAuth login framework and Codex as the initial device-authorization adapter. The provider-specific Codex requirements should be carried forward there.

  4. removed
    state:triage-neededOpened without agent diagnostics and needs triage
    on Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions