Skip to content

[rmcp-client] Preserve refresh tokens omitted by refresh responses - #26520

Closed
anp-oai wants to merge 3 commits into
mainfrom
codex/oauth-preserve-refresh-token-repro
Closed

[rmcp-client] Preserve refresh tokens omitted by refresh responses#26520
anp-oai wants to merge 3 commits into
mainfrom
codex/oauth-preserve-refresh-token-repro

Conversation

@anp-oai

@anp-oai anp-oai commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Intent

Some OAuth providers successfully refresh an access token without returning a new refresh_token. Codex should treat that omission as keeping the existing refresh token, not revoking it.

User-visible behavior

Before

Codex could erase a still-valid existing refresh token when a provider omitted refresh_token from a successful refresh response. A later refresh would then fail and force the user through a fresh login.

After

Codex preserves the existing refresh token when a successful response omits it. If the provider explicitly returns a replacement, that replacement wins. The preserved or replaced token remains available across repeated refreshes and client recreation.

Implementation

Add a narrow RMCP credential store that carries forward only an omitted refresh token before the running authorization manager updates its state. Codex persistence therefore observes the same corrected credentials.

Deterministic integration coverage exercises persistence across client recreation and three refreshes on one live client: omission, explicit replacement, then another omission using and preserving the replacement. It also asserts exact OAuth and MCP request counts.

Deferred scope

This PR does not change pre-existing concurrent persistor rollback behavior or future reauthorization and scope-upgrade semantics.

Validation not covered by CI

  • just test -p codex-rmcp-client omitted_refresh_token_preserves_running_manager_state -- --nocapture
  • just test -p codex-rmcp-client --test streamable_http_oauth_startup

@anp-oai anp-oai changed the title [rmcp-client] Reproduce omitted OAuth refresh token loss [rmcp-client] Preserve refresh tokens omitted by refresh responses Jun 5, 2026
@anp-oai

anp-oai commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

handing this off for now

@anp-oai anp-oai closed this Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant