Skip to content

Dispatch turn resume fails to find persisted user message after auth pause #1809

Closed

Description

@sentry-junior

An agent-dispatch turn paused for provider authorization. After authorization completed, the resume handler (beforeStart in packages/junior/src/chat/task-execution/paused-turn.ts) could not locate the persisted user message for the turn, so it treated the session as stranded and failed it via failStrandedTurnWithFallback (guard added for issue #727).

Observed once in production on release 0.204.0. Sentry JUNIOR-9D

Likely mechanism:

  • getTurnUserMessage matches on buildDeterministicTurnId(messageId) (turn_<messageId>), which never matches a dispatch turn id (dispatch:<dispatchId>), so dispatch resumes always depend on the dispatchUserMessage fallback.
  • That fallback requires the dispatch's synthetic input message (id agent-dispatch:<dispatchId>) to already be present in conversation.messages after hydrateConversationMessages. A single occurrence suggests a timing/race window where the auth-resume wakes the turn before that message is hydrated/visible.

To reproduce or narrow further:

  • Trigger a plugin/agent-dispatch turn that pauses for provider auth and complete auth quickly after the pause.
  • Check whether hydrateConversationMessages reliably includes the dispatch mailbox message immediately after wake.
  • Correlate with agent.turn.stranded_session.failed and turn.router.classifier.failed log events around the resume.

via neel.

--

View Junior Session [Sentry]

Activity

  1. added
    bug
    on Sep 9, 2026
  2. sentry-junior commented on Oct 30, 2026

    @sentry-junior
    ContributorAuthor

    Root cause found, and it's not the dispatch turn id. In every recent JUNIOR-9D event the turn id is the Slack reply turn id (turn_<slack ts>): a human replied in the thread under an automation/Watch post, so the turn ran in the agent-dispatch:… Conversation. The Slack turn saved its state, including that reply, under the Slack thread id instead of the owning Conversation id. When the turn paused for auth, resume read the owning Conversation, did not find the reply, and failed it as stranded. The fallback then posted the error as a new channel message because the dispatch Conversation id has no Slack thread.

    Fix and regression test: #2458

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