Repository navigation
Refresh Codex tokens without restarting running sessions - #155
Merged
Merged
Conversation
Keep refresh-token rotation owned by the server and bind helper requests to the launch profile so expiring sessions can renew safely.
Replace the expiring ACCESS_TOKEN environment with a self-invoked native auth command backed by the private server broker. Keep launch settings and the profile revision stable across refreshes, and fetch catalog tokens directly from auth.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why?
Managed Codex sessions fail with
401 token_expiredabout an hour after they start. BusyBoy resolves the ChatGPT access token once when a session opens and passes it to the long-livedcodex app-serverasACCESS_TOKEN(env_key). The process keeps that token for its whole life, so once it expires every request fails until the user restarts or signs in again. Long-running Codex tasks keep stalling on this.Upstream T3 Code had the same bug and fixed it in pingdotgg/t3code#21786 and pingdotgg/t3code#21787, a few days after BusyBoy forked.
How?
This ports that fix:
auth={command=<server binary>, args=["__managed-chatgpt-token", <socket>, <instance>, <environment>, <profile key>], refresh_interval_ms=0}. Codex runs it when it gets a 401 and retries the request once with the new token. No token is in Codex's env or argv any more.CodexManagedTokenBrokerlistens on a private socket (a 0600 Unix socket in a fresh 0700 directory, or a random named pipe on Windows). For each request it callsauth.access, which renews the token with the refresh token when needed, and writes back the token. It drops requests from another environment, andexpectedProfileKeyrefuses them after a different account signs in.__managed-chatgpt-tokenis a lean CLI fast path inbin.tsthat forwards the request to the broker and prints the token.revisionis the profile key, not the token, so a renewal does not restart the app-server or interrupt a running turn.auth.accessinstead of the env.