Skip to content

feat(events): Merge an Event batch into one task message - #2259

Merged
dcramer merged 4 commits into
mainfrom
feat/event-batch-message
Oct 27, 2026
Merged

dcramer merged 4 commits into
mainfrom
feat/event-batch-message

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

When several Watch Events arrive in one wait window, they already run in one Turn. But the Turn input pasted each Event's full task text together, so the Watch instructions repeated once per Event. The saved conversation message also kept only the first Event's type and summary. On #2245, an approval plus three Bugbot review comments reached the model as about 16KB with the same ~800-character instructions four times. The dashboard showed only "approved by dcramer".

Now each Event saves its task facts (label, instructions, guidance, people, Done by, summary, details, external text) on its mailbox input. The batch text is written when the Turn starts:

[task]

This is a task, not a message from a person.

You received 4 events.

About: GitHub PR getsentry/junior#2245
People involved: <@U123>
Instructions: <once per Watch>

Additional guidance:
- pull_request.review_comment.created: <once per event type>

Event 1: pull_request.review.approved
Done by: <@U123>. ...
Trusted summary: ...

Event 2: pull_request.review_comment.created
...

About: Vercel deployment junior-prod
Instructions: <this Watch's instructions>

Event 3: deployment.succeeded
...
  • Events are grouped by Watch, not by resource. Two Watches on the same PR keep separate instructions.
  • A single Event renders the same as before.
  • Input without saved facts, such as child agent results or input queued before this deploy, keeps its own text after the task block. It is not counted.
  • Root and child Conversations use the same batch input.
  • The conversation message keeps meta.eventType (the first Event) for existing readers and adds meta.events[] with one entry per counted Event. The reporting API exposes it under the same payload rules as the rest of the message.
  • The dashboard heading reads "N events · ", with one row per Event. The label shows only when every Event shares it. Messages without events render as before. I checked it on /dev/transcripts with a new fixture based on the feat(plugins): Add optional service accounts for plugins #2245 batch.

Duplicate handling is unchanged. The inbound id is still event:<watchId>:<eventKey>, so a repeated webhook delivery for the same Watch is dropped. Event automations don't batch and are not affected.

The conversation stats schemas moved to api/schema/conversation-stats.ts so api/schema/conversation.ts stays under the 1,000-line limit. Exports are unchanged.

Tests: the burst scenario in event-wake-delay.test.ts now goes through enqueueEventNotification. It uses a GitHub PR Watch (with guidance, people and Done by), a second Watch on the same PR, a Vercel deployment Watch, and a repeated delivery. It checks for one Turn, "You received 4 events", three instruction groups, the meta.events list, and the dropped duplicate. Removing the saved task facts now fails this test. The renderTaskBatchInput unit snapshot covers the exact layout.

An adversarial review pass found a test-architecture lint failure, child Conversations missing the batch input, a count mismatch with child results, and the test gap above. All are fixed here.

Not in this PR:

  • Fencing external text so a comment body can't imitate an Event N: line. The old format had the same gap.
  • Showing event times or arrival order across Watches. The README notes that numbering follows Watch groups.
  • Saying explicitly that Event text is not approval.
  • Dropping Events that cancel out, like a check that fails and then passes.
  • Dropping the extra review.commented sent with an approval body.
  • Nesting inline comments under their review.

via David Cramer.

--

View Junior Session [Sentry]

sentry-junior Bot and others added 4 commits October 27, 2026 22:29
Several Watch Events that share one Turn now become one task input:
"You received N events.", each Watch's instructions once, then each
Event. Mailbox input saves the task facts so the batch is written when
the Turn starts. The conversation message lists every Event, and the
dashboard shows them under one heading instead of only the first.

Move the conversation stats schemas to their own module so the
conversation schema stays under the file-length limit.

Co-Authored-By: David Cramer <[email protected]>

Co-Authored-By: David Cramer <[email protected]>
Check that Events from a GitHub PR Watch, a second Watch on the same
PR, and a Vercel deployment Watch become one task message with each
Watch's instructions once, and that a repeated delivery is dropped.

Co-Authored-By: David Cramer <[email protected]>
Child Conversations now write the same batch input as roots. The task
count and meta.events include only Watch Events with saved facts, so
they agree. Drop the unused group key fallback. The dashboard names the
resource only when every Event shares it.

Fold the mixed Watch case into the burst test and drive it through
enqueueEventNotification, so it covers the saved facts, guidance, and
people. Lower the test architecture baseline to match.

Co-Authored-By: David Cramer <[email protected]>
Main added an Event doer (doneBy) to the task input. Save it with the
task facts and render its Done by line for each Event in a batch, so
batching does not drop it.

Co-Authored-By: David Cramer <[email protected]>
@vercel

vercel Bot commented Oct 27, 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 Oct 27, 2026 10:32pm UTC

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

1 screenshot change — 1 changed · 0 added · 0 removed

Review screenshots in Frameshift

Gallery Transcripts · Desktop
Gallery Transcripts · Desktop
Changed

@dcramer
dcramer merged commit 9e93e73 into main Oct 27, 2026
44 checks passed
@dcramer
dcramer deleted the feat/event-batch-message branch October 27, 2026 22:44

This branch was successfully deployed

1 active deployment
Preview – junior-docs — ee9e9567 Deployed Oct 27, 2026 by vercel[bot]
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