[connectors] Refresh codex_apps /ps/mcp auth - #31486
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7b6616f512
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
stevenlee-oai
force-pushed
the
dev/stevenlee/fix-stale-codex-apps-auth
branch
2 times, most recently
from
July 7, 2026 23:13
4bb6f8f to
f260834
Compare
stevenlee-oai
force-pushed
the
dev/stevenlee/fix-stale-codex-apps-auth
branch
from
July 7, 2026 23:28
f260834 to
6f097aa
Compare
mzeng-openai
reviewed
Jul 7, 2026
| cancellation_token | ||
| }; | ||
| let current_runtime = self.services.latest_mcp_runtime(); | ||
| let codex_apps_auth_provider = auth.as_ref().and_then(|auth| { |
Contributor
There was a problem hiding this comment.
this has been repeated multiple times elsewhere, can we dedupe/simplify?
stevenlee-oai
force-pushed
the
dev/stevenlee/fix-stale-codex-apps-auth
branch
from
July 7, 2026 23:45
6f097aa to
e1e84d9
Compare
stevenlee-oai
force-pushed
the
dev/stevenlee/fix-stale-codex-apps-auth
branch
from
July 8, 2026 01:03
e1e84d9 to
8a1689a
Compare
anp-oai
reviewed
Jul 8, 2026
anp-oai
approved these changes
Jul 9, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Codex Thread 019f2408-dc59-79f2-b245-4c11debd1a61
Why
Long-lived Codex sessions can outlive the ChatGPT bearer token that was present when the MCP runtime started.
The Responses path already recovers from token expiration by refreshing or reloading the shared
AuthManager. The reservedcodex_appshosted-plugin client did not observe that update:McpConnectionManagerbuilt its/ps/mcpHTTP auth once from aCodexAuthsnapshot, andauth_provider_from_authcopied that snapshot bearer into a staticBearerAuthProvider.After the copied bearer expired,
/ps/mcpkept sending it even though Responses had a newer token in the sameAuthManager. The failure occurred before downstream connector execution, so unrelated apps such as Gmail, Slack, and Google Calendar could all fail with the same transport-level401 token_expired.This replaces openai/codex#29474, which was closed for inactivity without being merged. A new long-lived-session report reproduced the same simultaneous
/ps/mcpexpiry pattern across unrelated apps.What changed
AuthManager-backed request-header provider incodex-model-provider. It keeps anArc<AuthManager>and readsauth_cached()for each outbound request, so the next/ps/mcpcall sees a token refreshed by the existing Responses/auth-recovery flow.McpConnectionManagerconstruct the dynamic provider only for the reservedcodex_appsregistration used by the hosted-plugin/ps/mcppath.codex_appshosted-plugin/ps/mcpAuthManagerper requestcodex_appswithCODEX_CONNECTORS_TOKENNon-goals
/ps/mcp-initiated token refresh; this makes/ps/mcpobserve refreshes already performed through the sharedAuthManager.Tests
just test -p codex-model-providerjust test -p codex-mcpjust test -p codex-core mcp_auth_refreshcodex_apps/ps/mcpclient before the sharedAuthManagerchanges, updates that same manager through its public external-auth path, performs a realtools/call, and asserts the request uses the current bearer.