fix(resource-events): Frame event turns for humans and agents - #1639
Conversation
Shorten the inbound resource-event prompt and attach compact Slack reply attribution so event-driven replies show why they appeared. Co-Authored-By: David Cramer <david@sentry.io>
Co-Authored-By: David Cramer <david@sentry.io>
Co-Authored-By: David Cramer <david@sentry.io>
Use plain language for automated update instructions so the model prompt does not depend on product-specific subscription terms. Co-Authored-By: David Cramer <david@sentry.io>
Keep mailbox label/summary optional for in-flight rows, stamp verified summaries on durable conversation meta, and rebuild Slack reply chrome on resume. Prefer snapshot coverage for the agent event prompt. Co-Authored-By: David Cramer <david@sentry.io>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…aming # Conflicts: # packages/junior/src/chat/resource-events/notification.ts Co-Authored-By: David Cramer <david@sentry.io>
Reserve room for `(+N more)` before capping the latest summary so batched Slack reply attribution never slices the suffix.
Load turn_started input ids and collect durable resource-event messages so paused turns keep the same batched Slack footer as the live path.
Stamp drained resource-event steering into the durable conversation transcript so pause/resume can rebuild the same multi-update footer.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a8ae5b5. Configure here.
Count mid-turn resource events for live and resume Slack chrome only after the matching Pi checkpoint/steer or event-log commit succeeds, so failed drains cannot inflate the update footer.
After a successful mid-turn steer accept, treat resource-event chrome stamping as best-effort so a persistence error cannot reject the drain callback and redeliver already-steered mailbox messages.
There was a problem hiding this comment.
Self-review after stepping back from the review-bot ping-pong. The original product need is solid (short agent prompt + human-visible Slack context on event turns), but the PR has grown an unreliable second system around multi-update chrome durability.
1. Simplify the chrome path — drop the mid-turn stamp/resume machinery
stampResourceEventsAfterCommit in reply-executor.ts, plus loadTurnStarted / resourceEventMessagesForResume in the pause path, exist so resume can rebuild N updates · … (+N more) including events drained after turn start. That is what produced the last several findings (stamp-before-commit, stamp-after-accept rejecting the mailbox drain, suffix truncation). It is still fragile: chrome depends on a side-channel transcript write that is intentionally best-effort after steer, so live and resume can disagree by design.
For the MVP, chrome from the primary resource-event input (and anything already in turn_started / turn prep) is enough. Initial batch messages already go through toConversationMessage in turn prep with meta.summary. Prefer that simpler contract and delete the post-steer stamp helper and the resume transcript scan unless there is a concrete product requirement for mid-turn batch parity on day one.
2. Lock the product behavior with integration coverage, not more unit cases
Almost all new verification is pure unit tests of replyAttributionForResourceEventMessages / resourceEventMessagesForResume. Nothing in tests/integration asserts that a resource-event turn’s Slack reply actually carries Update · <summary> (or that resume keeps single-event chrome).
Extend the existing resource-event integration path (e.g. subscribed-message-behavior / agent-continue resume) through real reply wiring: mailbox message with resource_event_summary, run the turn, assert the outbound Slack payload/footer. That is the contract that was missing and that unit helper tests will not catch when the stamp path regresses again.
Prompt rewrite and single-update attribution shape look fine. I would ship those with a thin live path and one integration assertion, not the durability lattice.
Ship MVP Slack chrome from the primary event input and turn-prep batch only. Remove post-steer transcript stamping and resume reconstruction that disagreed with consumed input. Lock the product path with an integration assertion on the real sendSlackReply footer.
Keep the short agent event prompt and steer replies to say what changed and what was done. Move destination-visible footer chrome out of this change so the PR stays focused on prompt framing. Co-Authored-By: David Cramer <david@sentry.io>

Closes #1638.
Resource-event turns were landing in Slack as bare assistant replies with no trigger context. The agent prompt also carried long internal handling prose.
This MVP fixes both sides:
Update · <summary>(orN updates · <latest> (+N-1 more)).label/summarystay optional until in-flight pre-framing rows drain (TODO(v0.171.0)).Focused tests: 53 passed. Typecheck clean.
Requested by David Cramer.
--
View Junior Session [Sentry]