Skip to content

[Bug]: OpenAI/Codex OAuth Profile Not Attached to Inference Requests #90528

Closed

Description

@amoni094

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

Bug Report: OpenAI/Codex OAuth Profile Not Attached to Inference Requests

Environment

  • OpenClaw Version: 2026.6.1 (2e08f0f)
  • OS: Fedora Linux
  • Installation Method: npm global install
  • Auth Method: OpenAI OAuth (openclaw models auth login --provider openai --set-default)
  • OpenAI Account Type: ChatGPT Prolite subscription
  • Node: /usr/bin/node

Summary

OpenClaw successfully completes OpenAI OAuth login and stores a valid auth profile, but model inference requests are sent without an Authorization header.

The runtime consistently reports:

profile=-
401 Unauthorized
Missing bearer or basic authentication in header

This occurs with both:

openai/gpt-5.5
codex/gpt-5.5

Relevant Logs

Gateway startup:

[gateway] agent model: codex/gpt-5.5 (thinking=medium, fast=off)
[gateway] http server listening (3 plugins: codex, openshell, policy)

Inference failure:

[agent/embedded] embedded run failover decision:
reason=auth
from=codex/gpt-5.5
profile=-

401 Unauthorized:
Missing bearer or basic authentication in header

url: https://api.openai.com/v1/responses

Repeated failures also occur with:

from=openai/gpt-5.5
profile=-

Auth State

auth-state.json:

{
  "order": {
    "openai": [
      "openai:amoni094@gmail.com"
    ],
    "codex": [
      "openai:amoni094@gmail.com"
    ]
  },
  "lastGood": {
    "openai": "openai:amoni094@gmail.com",
    "codex": "openai:amoni094@gmail.com"
  }
}

auth-profiles.json contains a valid OAuth profile:

{
  "profiles": {
    "openai:amoni094@gmail.com": {
      "type": "oauth",
      "provider": "openai"
    }
  }
}

OAuth login completes successfully and refresh tokens are stored.


Additional Investigation Performed

Verified:

  • OAuth login succeeds
  • Auth profile exists
  • Auth profile order exists
  • OpenClaw reads auth state
  • Codex plugin installed and enabled
  • Codex plugin reinstalled from scratch
  • OpenClaw routing reset
  • Fallbacks cleared
  • New sessions created
  • Doctor fixes applied
  • Stale Codex session routing state removed

Issue persists.


Observed Conclusion

The selected OAuth profile appears to be ignored during inference.

The auth profile exists and is selected, but inference executes with:

profile=-

which results in requests being sent without an Authorization header.

This appears to be a bug in auth profile resolution or provider handoff during model execution.

Steps to reproduce

Reproduction Steps

  1. Install OpenClaw 2026.6.1
  2. Enable Codex plugin
  3. Login:
openclaw models auth login --provider openai --set-default
  1. Set model:
openclaw models set codex/gpt-5.5

or

openclaw models set openai/gpt-5.5
  1. Start gateway:
systemctl --user restart openclaw-gateway
  1. Test:
openclaw tui --session test --message "hello"

Expected behavior

Expected Behavior

After successful OAuth login:

Auth profile: openai:amoni094@gmail.com (openai/oauth)

model requests should be executed using that profile.

Expected log:

profile=openai:amoni094@gmail.com

and inference should succeed.


Actual behavior

Actual Behavior

Inference always fails:

from=openai/gpt-5.5 profile=-
401 Unauthorized: Missing bearer or basic authentication in header

and similarly:

from=codex/gpt-5.5 profile=-
401 Unauthorized: Missing bearer or basic authentication in header


OpenClaw version

2026.6.1

Operating system

Fedora 44 Silverblue

Install method

No response

Model

gpt 5.5; codex; gpt 5.4 mini; qren3:8b

Provider / routing chain

N/A

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

Severity high - openclaw doesn't work - only workaround to use codex directly for now

Additional information

No response

Activity

  1. clawsweeper commented on Jun 5, 2026

    @clawsweeper
    Contributor

    Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

    Current main and the v2026.6.6 release already cover the central failure: ordered OpenAI OAuth profiles are forwarded into Codex harness runs instead of leaving the inference path with profile=-; the separate migrated empty/default auth-store concern is tracked elsewhere.

    So I’m closing this as already implemented rather than keeping a duplicate issue open.

    Review details

    Best possible solution:

    Keep the shipped v2026.6.6/current auth-forwarding path for this inference handoff, and use #91352 for the distinct migrated empty/default auth-store problem.

    Do we have a high-confidence way to reproduce the issue?

    No current-main failure path remains from source inspection: the reported 2026.6.1 logs are credible, but current main and v2026.6.6 now forward the selected OpenAI OAuth profile into Codex harness attempts. I did not run live OAuth inference in this read-only review.

    Is this the best way to solve the issue?

    Yes. The current runtime-plan and scoped-store path is a better durable solution than only widening the bootstrap predicate because it forwards the Codex-owned OpenAI profile while preserving plugin-harness credential isolation.

    Security review:

    Security review: No PR diff or vulnerability report was under review; this pass only inspected existing auth routing behavior for issue triage.

    AGENTS.md: found and applied where relevant.

    What I checked:

    • Live issue context: The issue reports OpenClaw 2026.6.1 sending both codex/gpt-5.5 and openai/gpt-5.5 inference without an Authorization header despite a stored openai:* OAuth profile and auth order; later comments linked the attempted fix PR and a separate migration-empty-store data point.
    • Current main forwards harness auth profiles: Current main resolves forwardable plugin-harness auth profiles against the attempt auth store and the runtime auth plan, allowing a Codex harness to accept an openai:* profile instead of treating the provider as unauthenticated. (src/agents/embedded-agent-runner/run.ts:1000, dd7f2ef002e8)
    • Current main scopes the store passed to Codex: The runner now passes a scoped auth profile store containing only the forwarded plugin-harness candidate or last profile to plugin-owned harness attempts, so Codex receives the selected profile without exposing unrelated credentials. (src/agents/embedded-agent-runner/run.ts:1273, dd7f2ef002e8)
    • Codex app-server consumes the forwarded profile: The Codex app-server startup path prefers runtimePlan.auth.forwardedAuthProfileId before falling back to the request profile or binding profile, which is the handoff needed for the reported inference path. (extensions/codex/src/app-server/run-attempt.ts:453, dd7f2ef002e8)
    • Regression coverage exists on current main: The embedded runner tests assert explicit OpenAI Codex auth profiles are forwarded to Codex plugin harnesses and that the forwarded store contains openai:work; adjacent tests cover forced openai/* Codex runtime OAuth bootstrap and external overlay selection. (src/agents/embedded-agent-runner/run.overflow-compaction.test.ts:1006, dd7f2ef002e8)
    • Codex dependency contract checked: Sibling Codex source shows auth_provider_from_auth maps ChatGPT/OAuth auth snapshots to BearerAuthProvider, and that provider inserts the Authorization: Bearer ... header, so forwarding the OAuth profile store is the correct dependency contract for the missing-header failure. (../codex/codex-rs/model-provider/src/auth.rs:117, e5253b97fb6c)

    Likely related people:

    • 100yenadmin: PR history shows this account authored the merged runtime-plan suite that introduced Codex auth-profile forwarding and Codex app-server profile application. (role: feature owner; confidence: high; commits: 860dad268d35; files: src/agents/runtime-plan/auth.ts, extensions/codex/src/app-server/run-attempt.ts, extensions/codex/src/app-server/auth-bridge.ts)
    • steipete: PR history shows this account authored the OpenAI provider identity unification that touched the affected Codex/OpenAI auth and provider-routing surface cited in the discussion. (role: adjacent refactor owner; confidence: medium; commits: 4c33aaa86c16; files: src/agents/openai-routing.ts, src/agents/embedded-agent-runner/run.ts, extensions/codex/provider-catalog.ts)

    Codex review notes: model internal, reasoning high; reviewed against dd7f2ef002e8; fix evidence: release v2026.6.6, commit 8c802aa68351.

  2. wangmiao0668000666 commented on Jun 9, 2026

    @wangmiao0668000666
    Contributor

    I've analyzed this issue and identified the root cause. The regression was introduced in commit 4c33aaa ("refactor: unify OpenAI provider identity").

    When using codex/gpt-5.5, the provider resolves to codex instead of openai. However, the pluginHarnessNeedsOpenClawAuthBootstrap check in src/agents/embedded-agent-runner/run.ts:826 still requires provider === OPENAI_PROVIDER_ID, which evaluates to false for codex.

    This causes the auth store to be initialized as empty (createEmptyAuthProfileStore()), stripping out the OAuth profile and resulting in profile=-.

    Fix: Include codex in the bootstrap condition so OpenClaw properly loads and forwards auth profiles for Codex harness responses-API models.

    I'll submit a PR shortly.

  3. alexph-dev commented on Jun 9, 2026

    @alexph-dev
    Contributor

    Adding another related data point from a local 2026.6.x OpenAI/Codex OAuth setup. This may be one layer earlier than the profile=- runtime failure described here.

    Sanitized timeline/evidence:

    • openclaw doctor --fix --yes --non-interactive ran from the OpenClaw checkout at 2026-06-09 08:26:39 +08.
    • Around that same migration window, backups were created that still contained valid OAuth profiles:
      • auth-profiles.json.openai-provider-unification.*.bak with legacy openai-codex:* OAuth profiles.
      • auth-profiles.json.sqlite-import.*.bak with canonical openai:* OAuth profiles.
    • Later, the active per-agent auth-profiles.json was recreated as an empty store: {"version":1,"profiles":{}}.
    • The config still had the expected canonical route/order, but model/status checks reported OpenAI OAuth as missing and the gateway fell back to direct OpenAI API-key auth when OPENAI_API_KEY was present.
    • Manually repopulating/reimporting the OAuth profiles restored subscription/OAuth status.

    So the failure mode is not just “OAuth profile exists but is not attached to inference”; in this case valid OAuth profiles existed in migration backups, but the active auth store ended up empty after provider-unification / SQLite-import style migration. If this is covered by the same root cause, the fix should probably assert that doctor/import leaves the active auth store populated whenever it archives valid OAuth profiles.

    No tokens/profile IDs included here; all identifiers above are sanitized.

  4. added
    P2Normal backlog priority with limited blast radius.
    impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.
    P1High-priority user-facing bug, regression, or broken workflow.
    and removed
    P2Normal backlog priority with limited blast radius.
    on Jun 15, 2026
  5. locked as resolved and limited conversation to collaborators on Jun 25, 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

    P1High-priority user-facing bug, regression, or broken workflow.bugSomething isn't workingimpact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions