Repository navigation
feat(automations): Limit runs for each event automation - #2117
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
dcramer
reviewed
Oct 14, 2026
Each event automation can start at most 30 runs in a rolling hour. The limit is per automation, not per trigger type. When the window is full, ingest skips the dispatch, blocks the automation, and sends the creator the existing blocked notice. Provider retries do not count again, and resume clears the count. Event automations skip the consecutive automated-turn limit, so a noisy trigger could otherwise start a full agent turn for every event. Co-Authored-By: David Cramer <[email protected]>
Resume cleared the run log after the automation was active again, and the delete skipped the admission lock. A concurrent event could see the old full window and block the automation again, or write the old log back. Recreating a deleted automation did not clear the count at all. Clear the count under the admission lock, before the row becomes active. Blocked, paused, and deleted rows do not match events, so nothing can refill the count first. A resume of an already active automation keeps its count. Co-Authored-By: David Cramer <[email protected]>
Move the hourly run cap to botConfig.maxEventAutomationRunsPerHour so a
host can set it with createApp({ limits }). Lower the default from 30 to
10. The one-hour window stays fixed.
Capture one Sentry warning when the cap blocks an automation. All blocks
group under one fingerprint, with the automation id as extra data.
Co-Authored-By: David Cramer <[email protected]>
The per-automation run cap now blocks the 11th run in an hour, so the old scenario that sent 26 Events to one automation no longer holds. event-automation-blocking.test.ts owns the run cap behavior. Co-Authored-By: David Cramer <[email protected]>
Replace the locked, retry-aware run log with one cached count per automation. The window starts at the first run and lasts one hour. It takes no lock, so a run or two of slop under concurrency is accepted. A provider retry may count again, but the dispatch idempotency key still stops a second run. Co-Authored-By: David Cramer <[email protected]>
The get/set counter let concurrent Events all read the same count and pass the cap. Append one entry per run to a short state list instead, then count the entries from the last hour. The append is atomic, so the run that goes over the cap always sees it. Resume and revive append a reset entry, because the Redis adapter cannot delete list keys. A burst can now refuse runs that would fit, which blocks the automation. That is the safe side for a cap. Co-Authored-By: David Cramer <[email protected]>
Each run counted entries appended after it, so a burst could refuse every run and block the automation early. Give each entry an id and count only up to the run's own entry. The list order now decides which runs fit, so the first runs up to the cap pass. Co-Authored-By: David Cramer <[email protected]>
The run list keeps only the newest entries. After a burst bigger than the list, older runs from this hour can drop out, and a later run would count too few. When the list is full and its oldest entry is still in the hour, refuse runs until the next reset entry. Co-Authored-By: David Cramer <[email protected]>
#2114 added the stopped child agent status after #2122 added the status tone map, so the dashboard typecheck fails on main. Co-Authored-By: David Cramer <[email protected]>
sentry-junior
Bot
force-pushed
the
feat/event-automation-run-limit
branch
from
October 14, 2026 00:51
9048c64 to
6d308ce
Compare
Use the dispatch idempotency key as the run entry id and count distinct keys. A retry of the same Event finds its first entry, so it gets the same answer and does not use another run.
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 7bbecd5. Configure here.
A retry used its first entry even when a resume or revive came after it, so it could stay refused and block the automation again. Scan only the entries after the last reset entry.
dcramer
approved these changes
Oct 14, 2026
dcramer
added a commit
that referenced
this pull request
Oct 14, 2026
…es (#2119) A channel owner can now say "when someone posts a new message in this channel, answer it if you can, otherwise tag me". Junior runs an Event automation for each new top-level message and replies in that message's thread. This is the discuss-channel triage case in #2078. When Slack ingress drops a channel message (no mention, not a subscribed thread), it now publishes `slack` / `channel` / `message.posted` to `ingestEventAutomations`. Thread replies and bot posts do not publish. `chat/slack/channel-message-events.ts` owns the registration, the Event, the channel scope rule, and the reply thread. The `slack` namespace is core owned, like `junior`. The run's Destination adds the source message as `threadTs`. The stored Destination stays the channel. The event key is `channel:ts`, so Slack retries do not run twice. The run limit from #2117 still applies. Guardrails: - An automation can watch only its own channel (`current_channel`). Create and edit reject another channel, so private channel text stays in that channel. - Runs always use system credentials, because anyone in the channel writes the message. - `watchEvents` rejects the `slack` namespace. `pluginEventCatalog` is now `automationEventCatalog`, because it includes a core namespace. `createEventAutomation` is now always registered for Slack actors. Not in this PR: Workflow Builder posts (#2034), an "unanswered after N minutes" mode, a behavioral eval, and a check that Junior is a member of the channel. Refs #2078 <!-- junior-request-attribution:start --> via **David Cramer**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AC0AHB7N2JCR%3A1791930429.472169 --> -- [View Junior Session](https://junior-prod.sentry.dev/conversations/slack%3AC0AHB7N2JCR%3A1791930429.472169) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0AHB7N2JCR%3A1791930429.472169/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]>
This was referenced Nov 9, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Event automations skip the consecutive automated-turn limit (each dispatch runs in its own Conversation). So a noisy trigger can start a full agent Turn for every Event, with no cap. This blocks the Slack channel-message trigger proposed in #2078, where a busy channel could mean 50 Turns a minute.
This change caps the runs that each Event automation can start in a rolling hour.
botConfig.maxEventAutomationRunsPerHoursets the cap. The default is 10, and a host can change it withcreateApp({ limits: { maxEventAutomationRunsPerHour } }). The one-hour window is fixed. The cap is per Automation, not per trigger type or namespace. Another Automation on the same trigger keeps its own count.event-automations/run-limit.tskeeps a small per-automation run log in the state adapter. The log expires with the window.ingestEventAutomationsadmits each run before dispatch. The run key is the dispatch idempotency key, so a provider retry of a counted Event does not count again.blockEventAutomationandnotifyAutomationBlocked, so the creator gets one DM. Blocked rows do not match later Events.Event automation blocked by run limit. All blocks group under the fingerprintevent_automation.run_limit.blocked, withapp.task.id, the event namespace and type, and the cap as data. Events refused after the block do not capture again.Scheduled automations are unchanged, because they already run at most once a day.
Tests
tests/integration/event-automation-blocking.test.tswith one scenario: fill the window, check that a retry does not count, check that old runs leave the window, check that a sibling Automation on the same trigger keeps running while the full one blocks with one notice, and check that resume and revive clear the count.chat-config.test.tsandapp-model-config.test.tscover the default and thecreateAppoverride.pnpm typecheck,pnpm lint, and the event-automation and config test files pass. One exception:event-automations.test.ts > delivers the current automation card…fails the same way onmainin my sandbox, because live title generation changes the card label. It is not related to this change.Refs #2078, #2051
via David Cramer.
--
View Junior Session [Sentry]