Skip to content

fix(events): wait for watch event bursts - #1831

Merged
dcramer merged 10 commits into
mainfrom
fix/watch-event-debounce
Sep 11, 2026
Merged

fix(events): wait for watch event bursts#1831
dcramer merged 10 commits into
mainfrom
fix/watch-event-debounce

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Watch events now wait briefly before they start a Turn.

  • The first event waits 30 seconds.
  • Each extra event adds 5 seconds.
  • The total wait cannot exceed 60 seconds from the first event.
  • Human messages are not delayed.
  • Event IDs still prevent duplicate mailbox messages.

The wait is computed from the pending messages. It needs no new stored state.

Fixes #1829.

Checks:

  • focused integration test
  • Junior typecheck
  • full workspace lint
  • file-length and formatting checks

via David Cramer.

--

View Junior Session [Sentry]

Co-Authored-By: David Cramer <david@sentry.io>
@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
junior-docs Ready Ready Preview Sep 10, 2026 7:41pm UTC

Request Review

sentry-junior Bot and others added 2 commits September 10, 2026 18:39
This reverts commit 0283a75.

Co-Authored-By: David Cramer <david@sentry.io>
Replace the flat pre-delay with a debounce owned by the event Turn
worker: the first event waits 30s, each additional pending event adds
5s, and the wait is capped at 60s measured from the first event. This
lets a burst of watch events collect into one Turn without needing a
persisted debounce deadline or a second scheduling mechanism.

Co-Authored-By: David Cramer <david@sentry.io>
@dcramer
dcramer marked this pull request as ready for review September 10, 2026 18:54
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Sep 10, 2026
Co-Authored-By: David Cramer <david@sentry.io>
@sentry-junior sentry-junior Bot changed the title fix(events): debounce watch event wakes fix(events): wait for watch event bursts Sep 10, 2026

@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.

Stale Bugbot comment from a previous run.

Comment thread packages/junior/src/chat/task-execution/conversation-turn.ts
Co-Authored-By: David Cramer <david@sentry.io>

@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.

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 f6b1729. Configure here.

Comment thread packages/junior/src/chat/conversations/web-input.ts Outdated
Cursor Bugbot flagged that Slack (and any other non-web) inbound
messages went through appendAndEnqueueInboundMessage without
replaceExistingWake, so a pending event enqueue marker could swallow
their wake and force them to wait out the event delay.

Move the default to the shared enqueueAfterAppend choke point: any
message whose source is not "event" now defaults to
replaceExistingWake, covering Slack, dispatch, and invocation callers
without needing every call site to opt in.
Non-event input must bypass an event's delayed enqueue marker, but it must not bypass a worker that already owns the conversation lease. Split those controls so Slack steering stays in the active worker without redundant queue nudges.
Comment thread packages/junior/src/chat/task-execution/conversation-turn.ts
Add comments explaining why the mailbox worker defers a batch that starts with an event, how the debounce window grows with batch size, and why deferral re-enqueues instead of sleeping.
@dcramer
dcramer merged commit a9c7a59 into main Sep 11, 2026
40 checks passed
@dcramer
dcramer deleted the fix/watch-event-debounce branch September 11, 2026 01:58
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.

Watch event batches corrupt conversation transcripts

1 participant