Skip to content

bug: non-targeted bystander messages in a thread incorrectly abandon auth-paused auto-resume #695

Closed

Description

@dcramer

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)

  1. ckj (@U024ZCV9W) asks @junior do you have the ability to write information to a notion database?
  2. Junior pauses: "I'll need you to authorize Notion. I sent you a link."
  3. david (not targeting Junior) replies in-thread: "i think its only read only tools but i forget…"
  4. ckj completes OAuth in the browser.
  5. Auto-resume is abandoned — ckj has to re-@-mention Junior ("@junior i should be authorized now") to get a response.
  6. 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 new activeTurnId → resume blocked by the activeTurnId !== resumeSessionId guard in oauth-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 project 4510944073809921 can confirm frequency.

View Session in Sentry

Activity

  1. added
    bug
    on Jun 30, 2026
  2. added a commit that references this issue on Jun 30, 2026
    e03a8ea
  3. added a commit that references this issue on Jul 17, 2026
    0023630
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions