Skip to content

refactor(oauth): scope callback serving to authorization - #4694

Merged
dgageot merged 1 commit into
mainfrom
refactor/oauth-callback-run
Oct 21, 2026
Merged

dgageot merged 1 commit into
mainfrom
refactor/oauth-callback-run

Conversation

@dgageot

@dgageot dgageot commented Oct 21, 2026

Copy link
Copy Markdown
Member

Drop the long-lived CallbackServer (New/Start/Wait/Shutdown) in favor
of a single blocking RequestAuthorizationCode(ctx, port, prepare) that owns
its listener/server/handler for one run.

  • Binds the loopback listener before the caller synchronously prepares
    credentials/authorization URL, so the redirect target is live earlier
  • Per-run state and result are isolated instead of shared across the server's
    lifetime
  • Duplicate callback requests are now permanently arbitrated (first one wins)
    rather than racily accepted, fixing a user-observable duplicate-code bug
  • Server errors are propagated to the caller instead of being silently
    swallowed
  • Shutdown is bounded with a graceful attempt, a force-close fallback, and
    joins on completion

Migrates managed MCP OAuth, standalone OAuth login, and the remote runtime
callers, plus all associated tests/helpers to the new API.

This PR is scoped to the OAuth callback refactor only — no lint or resize
changes included.

Validation

  • task build, task test, task lint
  • oauthflow tests repeated with -race, 20+ runs
  • Focused MCP/runtime OAuth tests repeated 5+ runs
  • Cross-compiled (no test run) GOOS=windows and GOOS=linux amd64,
    CGO_ENABLED=0, for ./pkg/tools/mcp/... and ./pkg/runtime/...
  • Cross-compiled (no test run) GOOS=js GOARCH=wasm for
    ./pkg/tools/mcp/oauthflow and ./cmd/wasm

Drop the long-lived CallbackServer type in favor of a single blocking
RequestAuthorizationCode call that owns its listener/server/handler for
one run, binds before the caller prepares the authorization request, and
joins everything on return. Migrates managed, standalone and remote
callers.

Assisted-By: docker-agent
@dgageot
dgageot requested a review from a team as a code owner October 21, 2026 18:37
@aheritier aheritier added area/mcp MCP protocol, MCP tool servers, integration area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection kind/refactor PR refactors code without behavior change labels Oct 21, 2026
@dgageot
dgageot added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit ed6fb55 Oct 21, 2026
16 checks passed
@dgageot
dgageot deleted the refactor/oauth-callback-run branch October 21, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/mcp MCP protocol, MCP tool servers, integration area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection kind/refactor PR refactors code without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants