Skip to content

Skip refresh for account-pilot managed Codex credentials - #3

Merged
khairm merged 2 commits into
edgee-oauth-base-urlfrom
skip-refresh-pilot-managed
Nov 6, 2026
Merged

khairm merged 2 commits into
edgee-oauth-base-urlfrom
skip-refresh-pilot-managed

Conversation

@khairm

@khairm khairm commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Why

account-pilot keeps each server's Codex access token fresh from the Pi. It writes a placeholder refresh_token (managed-by-usage-display-tray) and a trayManagedAccount marker. The placeholder is there on purpose, so that a local refresh fails instead of rotating the Pi's real login dead.

The Codex refresh lead is 5 days, and the Pi serves tokens with about 4 days left. So CLIProxyAPI sent the placeholder to auth.openai.com on every start (3 attempts) and logged background credential refresh failed … 401 token_expired. That 401 also marked the auth unauthorized until the next pilot write.

Change

authRefreshedExternally checks for the trayManagedAccount marker. A marked credential is:

  • never scheduled by the background refresh loop (nextRefreshCheckAt);
  • never refreshed after a request 401 (authHasRefreshCredential). The 401 still surfaces to the caller, as it does for any credential without a refresh token.

Tests

  • TestPilotManagedAuthIsNeverScheduledForBackgroundRefresh: a control auth without the marker is scheduled; a marked one is not.
  • TestPilotManagedAuthSurfacesUnauthorizedWithoutRefreshing: a request 401 returns the 401, with 0 refresh calls.
  • Both fail with the fix reverted. go test -race ./sdk/cliproxy/auth and go vet pass, and the package is already in the release gate.

Proof

I ran two throwaway local binaries with a fake pilot-shaped auth file (no real tokens) and a dummy proxy that logs and refuses CONNECTs:

Binary auth.openai.com CONNECTs Refresh-failure log lines
6fc6e9b (base) 3 1
This branch 0 0

Release as edgee.10 when merged.

🤖 Generated with Claude Code

Update: sentinel refresh token also counts as managed

The owner's PC gateway (write_cliproxy_codex_auth in codex-proxy-for-claude-code) writes codex-tray.json with the same placeholder refresh token, managed-by-usage-display-tray, but no trayManagedAccount marker. authRefreshedExternally now also treats a login whose refresh_token/refreshToken equals that exact sentinel as managed (constant pilotSentinelRefreshToken).

Tests: both tests now cover a marker-only login (real refresh token) and a sentinel-only login (no marker), and the scheduler test keeps an unmanaged control. Removing either check fails its matching case.

account-pilot keeps the Codex access token fresh from the Pi and writes a
placeholder refresh token plus a trayManagedAccount marker. CLIProxyAPI's
5-day Codex refresh lead made it send that placeholder to auth.openai.com on
every start, log a 401 and mark the auth unauthorized until the next write.
Marked credentials are now never scheduled for background refresh and never
refreshed after a 401; a request 401 still surfaces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 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-11-06T17:53:54.846744Z c0e99a9 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.

The PC gateway writes codex-tray.json with the placeholder refresh token
but no trayManagedAccount marker, so treat the exact sentinel as managed too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@khairm
khairm merged commit 40b35f6 into edgee-oauth-base-url Nov 6, 2026
3 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.

1 participant