ref(seer): Move seer automation guards into the task - #121462
Conversation
`kick_off_seer_automation` runs inline in post-process for every event, so all of its eligibility work (org tier lookup, group fields, cache read, lock check, rate limiting) was on the hot path. Move that into `generate_summary_and_run_automation` and leave only the killswitch check plus the task dispatch in post-process. The killswitch previously only guarded the seat-based path; it now short circuits the whole step, which is the only thing left outside the task. `kick_off_seer_automation` is the sole caller of the task, so no other entry point picks up the new guards.
The moved guards' imports don't need to be function-local, so lift the whole set of sentry.seer.autofix imports (including the ones the other tasks in this module were importing locally) to the top of the file. Retargets the one test patch that relied on the late binding.
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 700cc3a. Configure here.
| bulk_read_preferences_from_sentry_db, | ||
| get_org_default_seer_automation_handoff, | ||
| get_seer_seat_based_tier_cache_key, | ||
| is_seer_seat_based_tier_enabled, |
There was a problem hiding this comment.
Seat-based guard tests patch stale target
Low Severity
The seat-based guards moved out of kick_off_seer_automation, but the tests covering them still patch sentry.seer.autofix.utils.is_seer_seat_based_tier_enabled and exercise post-process. Since sentry.tasks.seer.autofix binds that name at import time, the patch no longer reaches the relocated logic, so those tests pass without validating the guards, leaving the new task-side behavior uncovered.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 700cc3a. Configure here.
Mihir-Mavalankar
left a comment
There was a problem hiding this comment.
We need to just find a way to remove issue summary and fiability from this hot path. I think that is the better long term solution.
| return | ||
|
|
||
| generate_summary_and_run_automation.delay(group.id, trigger_path="old_seer_automation") | ||
| generate_summary_and_run_automation.delay( |
There was a problem hiding this comment.
This will break taskbroker. AFAIK this line of code is called for every event in every issue and so it will spawn a task for every event in every issue.


Currently the post process step:
kick_off_seer_automation:This reorganizes the code to:
We trade "always doing some work" in the hot path for "always spawning a task" in the hot path.
This came up as part of inc-2410. It seems like
is_seer_seat_based_tier_enabled(which is called tocheck eligibility) slowed down - this broke ingestion.
The killswitch is left in the initial call.