Skip to content

fix(agent-plugins): preserve rotating OAuth grants under concurrent requests - #15

Open
TarasKosh wants to merge 2 commits into
patleeman:mainfrom
TarasKosh:fix/saga-345-oauth-refresh
Open

TarasKosh wants to merge 2 commits into
patleeman:mainfrom
TarasKosh:fix/saga-345-oauth-refresh

Conversation

@TarasKosh

@TarasKosh TarasKosh commented Nov 17, 2026 •

Copy link
Copy Markdown

After access expiry, concurrent MCP requests can refresh the same rotating OAuth token. One renewal succeeds while another receives invalid_grant; the SDK can then clear the newly saved credentials and require another login.

This change coordinates SDK renewal per credential provider, reuses the saved winner for late 401 responses, and preserves parallel authenticated reads. Rejected renewal reports needs-auth and stops automatic replay. Previously challenged scopes remain available to the SDK's later scope step-up without changing authorization-server-issued token scopes. The official SDK OAuth flow, secure secret backend, resource binding and per-server identity remain in place.

Validation:

  • 101 package tests across 16 files pass, including 12 real HTTP/official SDK cases covering expiry, concurrent and late 401 responses, rotation, reconstruction, revocation, provider isolation and scope preservation.
  • The original gateway fails the concurrent-refresh regressions while the single-request control passes. Three scope regressions fail before the follow-up correction and pass afterward.
  • Typecheck, plugin build, stable BB 0.49.0 compatibility, marketplace schema and index/asset checks pass.
  • Independent local review passes all six aspects at a156e6878676065725edd12b23917c49131042f3, with 20 targeted checks. The earlier review of 594a54d found the scope regression; that finding is retained and closed by the follow-up. The review report was supplied privately and has not been published as a GitHub review.

No installed/live OAuth validation has been performed. Remote MCP server persistence across restarts is a separate follow-up. The reproduced client defect does not establish the exact cause of a historical live incident.

Delivery: the affected installation tracks agent-plugins/^0.3.0; this main-based candidate has package version 0.4.0. A compatible backport/release is needed for an update within that channel. A full 0.4.0 update also includes upstream attention UI and pasted-callback changes since 0.3.1.

Runtime behavior changed: yes
Living contract changed: no

@TarasKosh
TarasKosh marked this pull request as ready for review November 18, 2026 01:20
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.

2 participants