Skip to content

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

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

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions