Repository navigation
fix(runtime): Resume OAuth turns through the conversation worker - #1913
Conversation
Co-Authored-By: David Cramer <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Keep OAuth callbacks out of agent execution and history writes. Save authorization readiness for the paused checkpoint, then let the existing worker lease own continuation. Remove duplicate callback execution and the extra resume lock. Prove both OAuth-first and event-first ordering through real queue wiring. Replace stale thread-lock recovery coverage with the worker lease contract. Co-Authored-By: David Cramer <[email protected]>
The MCP callback now queues continuation before it returns. Accept success without waitUntil work in its harness test while retaining the generic OAuth and unexpected-background-work guards.
|
6 screenshot changes — 6 changed · 0 added · 0 removed Review screenshots in Frameshift |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit bd69c6d. Configure here.
| ...(routing.location ? { location: routing.location } : undefined), | ||
| source, | ||
| ...(surface ? { surface } : undefined), | ||
| toolChannelId: destination.channelId, |
There was a problem hiding this comment.
Dispatch OAuth resume branches history
High Severity
The worker records authorization_completed in conversation history, then a dispatch resume feeds the agent piMessages that omit that event. The next checkpoint prefix-check fails with AgentHistoryBranchError, so the authorized Turn never continues.
Reviewed by Cursor Bugbot for commit bd69c6d. Configure here.
| (!("userId" in actor) || actor.userId !== authorization.actorId) | ||
| ) { | ||
| throw new Error("Authorization actor does not match the paused Turn"); | ||
| } |
There was a problem hiding this comment.
System-actor OAuth resumes are rejected
Medium Severity
The new resume check requires the paused Turn actor to have a userId equal to the authorizing user. Event and other system Turns store EVENT_SYSTEM_ACTOR, so a valid user OAuth callback fails the Turn instead of continuing it.
Reviewed by Cursor Bugbot for commit bd69c6d. Configure here.
| authSession, | ||
| queue: options.conversationWorkQueue, | ||
| provider, | ||
| }); |
There was a problem hiding this comment.
Wake errors fail completed OAuth
Medium Severity
Slack OAuth now awaits queue wake after tokens are stored and the one-time session or state is deleted. A later event-store or queue error is returned as authorization failure, so the original Turn never resumes and the user cannot retry the same callback.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit bd69c6d. Configure here.


An OAuth-resumed Turn could run beside queued work in the same Conversation. Both runs changed agent history. The resumed Turn then failed to save its continuation with
AgentHistoryBranchError.Route Slack OAuth continuation through the existing conversation worker. Callbacks store an idempotent
turn_authorizedevent for the paused checkpoint and wake the queue. Only the worker records authorization in agent history and runs the Turn, under its conversation lease. It checks the pending request, actor, provider, scope, and MCP attempt before resuming.Remove the duplicate MCP and plugin OAuth execution paths, their result/failure handlers, and the extra resume lock. Preserve the local CLI and dashboard callback paths. Keep persisted MCP configuration and tool channel when the worker rebuilds the Run.
This replaces the first shared-lock patch. A regression proved that patch fails when queued event work starts first: its execution lock blocks the OAuth credential write. Queue ownership avoids both orderings without another execution lock.
Validation:
Evidence: Sentry event.
via David Cramer.
--
View Junior Session [Sentry]