Client or integration
Codex CLI
Area
Authentication and account pool
Summary
When the native Codex __main__ account has an expired access token in ~/.codex/auth.json but still has a valid refresh token, OpenCodex can select that account and forward the expired bearer to /v1/responses. The request returns 401 instead of refreshing the native credential first. Stored account-pool credentials have a refresh path, but the native main credential does not pass through it.
Expected behavior: OpenCodex refreshes the native main credential before upstream I/O. If upstream rejects that bearer once with 401, OpenCodex refreshes and replays the request once with the new bearer.
Reproduction
- Use OpenCodex at commit
caf20353fa87bf14c5fef078e5d8b0692dd7c92d on the dev branch.
- Configure the Codex native main account in
~/.codex/auth.json with an expired access token and a non-empty valid refresh token. Ensure no other account-pool credential is currently usable.
- Start the local proxy with
ocx start --port 10100.
- Send a normal Codex CLI request through
http://127.0.0.1:10100/v1/responses.
- Observe that the native
__main__ account is selected, but its expired access token is forwarded without first using the refresh token.
- Observe the 401 response shown below. The request succeeds only after credentials are refreshed outside this native-main request path.
The same missing native credential substitution affects /v1/responses/compact.
Version
caf20353fa87bf14c5fef078e5d8b0692dd7c92d (dev, before PR #2222)
Operating system
Ubuntu 24.04.4 LTS
Provider and model
OpenAI Codex native account; model-independent
Logs or error output
unexpected status 401 Unauthorized: OpenAI account pool has no usable account credential, url: http://127.0.0.1:10100/v1/responses
Screenshots and supporting files
PR #2222 contains focused regression tests for pre-request refresh, one-time 401 recovery, compact routing, refresh-token rotation, and native/stored credential convergence.
Redacted configuration
{
"native_main": {
"access_token": "<expired-redacted>",
"refresh_token": "<valid-redacted>"
},
"other_usable_pool_accounts": 0
}
Checks
Client or integration
Codex CLI
Area
Authentication and account pool
Summary
When the native Codex
__main__account has an expired access token in~/.codex/auth.jsonbut still has a valid refresh token, OpenCodex can select that account and forward the expired bearer to/v1/responses. The request returns 401 instead of refreshing the native credential first. Stored account-pool credentials have a refresh path, but the native main credential does not pass through it.Expected behavior: OpenCodex refreshes the native main credential before upstream I/O. If upstream rejects that bearer once with 401, OpenCodex refreshes and replays the request once with the new bearer.
Reproduction
caf20353fa87bf14c5fef078e5d8b0692dd7c92don thedevbranch.~/.codex/auth.jsonwith an expired access token and a non-empty valid refresh token. Ensure no other account-pool credential is currently usable.ocx start --port 10100.http://127.0.0.1:10100/v1/responses.__main__account is selected, but its expired access token is forwarded without first using the refresh token.The same missing native credential substitution affects
/v1/responses/compact.Version
caf20353fa87bf14c5fef078e5d8b0692dd7c92d(dev, before PR #2222)Operating system
Ubuntu 24.04.4 LTS
Provider and model
OpenAI Codex native account; model-independent
Logs or error output
Screenshots and supporting files
PR #2222 contains focused regression tests for pre-request refresh, one-time 401 recovery, compact routing, refresh-token rotation, and native/stored credential convergence.
Redacted configuration
{ "native_main": { "access_token": "<expired-redacted>", "refresh_token": "<valid-redacted>" }, "other_usable_pool_accounts": 0 }Checks