Repository navigation
Description
Summary
When Junior pauses mid-turn to request OAuth authorization, any non-targeted message posted in the same thread by a bystander (someone not @-mentioning Junior) causes the auth auto-resume to be abandoned once the user completes auth. The user then has to re-@-mention Junior manually to continue.
Expected behavior: after auth completes, Junior should auto-resume the original task unless there has been explicit steering — i.e., a new direct instruction to Junior (explicit @-mention, DM, or equivalent). Bystander chatter (non-targeted messages that Junior recorded as skipped) should not block the resume.
Observed scenario (concrete thread evidence)
- ckj (@U024ZCV9W) asks
@junior do you have the ability to write information to a notion database? - Junior pauses:
"I'll need you to authorize Notion. I sent you a link." - david (not targeting Junior) replies in-thread:
"i think its only read only tools but i forget…" - ckj completes OAuth in the browser.
- Auto-resume is abandoned — ckj has to re-@-mention Junior (
"@junior i should be authorized now") to get a response. - Junior then answers correctly once re-triggered.
Root cause
isPendingAuthLatestRequest in packages/junior/src/chat/services/pending-auth.ts scans conversation.messages in reverse and returns false (meaning "no longer the latest request") whenever ANY newer user-role message exists, regardless of whether it was a skipped bystander message:
export function isPendingAuthLatestRequest(
conversation: ThreadConversationState,
pendingAuth: ConversationPendingAuthState,
): boolean {
for (let index = conversation.messages.length - 1; index >= 0; index -= 1) {
const message = conversation.messages[index];
if (message?.role !== "user") {
continue;
}
// BUG: does not skip skipped/non-steering messages
return buildDeterministicTurnId(message.id) === pendingAuth.sessionId;
}
return false;
}When david's non-targeted comment arrives as a subscribed_message and is processed via skipSubscribedMessage → recordSkippedSubscribedTurn, it is written into conversation.messages as a user-role message with meta.replied: false and meta.skippedReason set.
When the OAuth callback then calls isPendingAuthLatestRequest, it finds david's skipped message as the "latest user message", returns false, and the callback abandons the resume with:
"Auth completed after a newer thread message abandoned this blocked request."
Fix
In isPendingAuthLatestRequest, skip messages that have meta.skippedReason set. Only messages that were actually acted upon (replied to, currently active, or auth-paused) should count as the "latest effective request":
export function isPendingAuthLatestRequest(
conversation: ThreadConversationState,
pendingAuth: ConversationPendingAuthState,
): boolean {
for (let index = conversation.messages.length - 1; index >= 0; index -= 1) {
const message = conversation.messages[index];
if (message?.role !== "user") {
continue;
}
// Non-targeted bystander messages are recorded with skippedReason.
// They are not steering and should not block auth resume.
if (message.meta?.skippedReason) {
continue;
}
return buildDeterministicTurnId(message.id) === pendingAuth.sessionId;
}
return false;
}This correctly handles all cases:
- Bystander chatter → has
skippedReason→ skipped → resume proceeds ✅ - New explicit @-mention to Junior → has no
skippedReason, becomes newactiveTurnId→ resume blocked by theactiveTurnId !== resumeSessionIdguard inoauth-callback.ts✅ - No newer messages → the auth-blocked message is still the latest → resume proceeds ✅
Affected file
packages/junior/src/chat/services/pending-auth.ts → isPendingAuthLatestRequest
Related
- The abandonment error message is:
"Auth completed after a newer thread message abandoned this blocked request."— a Sentry search for this in project4510944073809921can confirm frequency.
Activity
fix(auth): Hard-fail bot authorization requests
fix(auth): Hard-fail bot authorization requests (getsentry#700)
fix(github): Stay silent while a draft's required checks are unfinish…
test(evals): Serve the draft commits and GitHub status that integrati…