Skip to content

fix(runtime): Keep deferred messages out of active turns#1014

Merged
dcramer merged 10 commits into
mainfrom
fix/resource-events-follow-up-queue
Jul 24, 2026
Merged

fix(runtime): Keep deferred messages out of active turns#1014
dcramer merged 10 commits into
mainfrom
fix/resource-events-follow-up-queue

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Each inbound mailbox message now has one delivery mode:

  • interrupt is used only for Slack @ mentions and may join the active turn at the next safe point.
  • defer is used for every other inbound message and waits for the next normal turn.

Messages are batched by delivery mode. All pending interrupts are handled together first, regardless of when they were queued. When no interrupts remain, all deferred messages are handled together in the next turn.

The delivery mode is stored with the mailbox message, so retries and worker restarts do not change it. Older mailbox records are upgraded to defer, invalid current records fail instead of silently dropping work, and a later mention event can promote a duplicate deferred Slack message to interrupt.

Queue callbacks remain small conversation wake-ups; the persisted mailbox owns the destination, message content, and delivery mode.

Requested by David Cramer via Junior.

--

View Junior Session

@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
junior-docs Ready Ready Preview Jul 23, 2026 10:32pm

Request Review

@sentry-junior sentry-junior Bot changed the title fix(runtime): Keep resource events out of steering fix(runtime): Model mailbox routing explicitly Jul 23, 2026
@dcramer dcramer changed the title fix(runtime): Model mailbox routing explicitly fix(runtime): Preserve mailbox delivery semantics Jul 23, 2026
@dcramer dcramer changed the title fix(runtime): Preserve mailbox delivery semantics fix(runtime): Keep deferred messages out of active turns Jul 23, 2026
@dcramer
dcramer marked this pull request as ready for review July 23, 2026 19:27
@github-actions github-actions Bot added the risk: high PR risk score: high label Jul 23, 2026
Comment thread packages/junior/src/chat/task-execution/state.ts Outdated
Comment thread packages/junior/src/chat/task-execution/state.ts Outdated
sentry-junior Bot and others added 8 commits July 23, 2026 13:36
Co-Authored-By: David Cramer <david@sentry.io>
Co-Authored-By: David Cramer <david@sentry.io>
Co-Authored-By: David Cramer <david@sentry.io>
Resolve mailbox acknowledgements and deferrals through one atomic drain operation while keeping agent steering terminology at the runtime boundary.
Describe how pending input is delivered into turn execution without overloading routing terminology used for destinations and handlers.
Version and strictly validate durable mailbox messages, preserve interrupt delivery across duplicate ingress, and keep metadata mirroring aligned with actual drain mutations.
Assign interrupts only to Slack mentions, queue all other inbound work as deferred, and batch pending work by delivery priority.
Comment thread packages/junior/src/chat/task-execution/state.ts
Comment thread packages/junior/src/chat/task-execution/state.ts
When a duplicate Slack mention promotes deferred work to an interrupt, retain the mention metadata while preserving attachments already captured from its twin event.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ff86163. Configure here.

Comment thread packages/junior/src/chat/task-execution/slack-work.ts Outdated
Derive interrupts from explicit Slack mentions instead of broad DM routing, and ignore legacy injected markers without rejecting otherwise valid pending work.
@dcramer
dcramer merged commit 1d6fd2c into main Jul 24, 2026
56 of 61 checks passed
@dcramer
dcramer deleted the fix/resource-events-follow-up-queue branch July 24, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant