background-agents icon indicating copy to clipboard operation
background-agents copied to clipboard

feat(automations): per-automation hourly limit for bot-triggered Slack runs

Open open-inspect opened this issue 1 month ago • 0 comments

Summary

Make the hourly limit on bot-triggered runs configurable per automation. Today it is hardcoded (SLACK_BOT_TRIGGER_LIMIT = 10, SLACK_BOT_TRIGGER_WINDOW_MS = 1h in packages/control-plane/src/scheduler/slack-bot-trigger-policy.ts), added in #2557.

Motivation

The right limit depends on the bot. A cost-anomaly bot may post a couple of times a day, while a CI or monitoring bot in a busy channel can legitimately exceed 10 posts an hour. The limit is a backstop against a loop where a run's output makes another bot post, which starts the automation again. A single global value is either too loose for quiet bots or too tight for busy ones.

Proposal

  • Add an optional maxBotRunsPerHour to triggerConfig.slack, next to includeBotMessages, in packages/shared/src/triggers/types.ts. Keep the window at one hour.
  • Default to the current SLACK_BOT_TRIGGER_LIMIT (10) when absent, so existing automations keep today's behavior.
  • Validate it as a positive integer with an upper bound, so the loop guard can't be disabled (automation-validation.ts).
  • SlackBotTriggerPolicy.limitReached reads the automation's value instead of the constant (pass the parsed trigger config, as accepts already does).
  • Web: a number input under Trigger on bot messages, shown only when it is on. Show the value on the automation detail page.
  • Update the run-history skip label, docs/AUTOMATIONS.md and packages/docs/content/docs/automations/slack-messages.mdx, which currently say "10".

Out of scope

  • A configurable window length.
  • A strict quota. The check stays a soft pre-admission count, and simultaneous bursts can still exceed it, as documented in #2557.

Tests

  • Policy: uses the configured limit and falls back to the default when it is absent.
  • Route validation: rejects zero, negative, non-integer and over-bound values.
  • Web form: the input appears only with bot messages on, and its value round-trips on edit.

open-inspect avatar Oct 27 '26 05:10 open-inspect