Skip to content

feat(seer): Allow max candidate override on admin night shift trigger#113222

Merged
trevor-e merged 8 commits intomasterfrom
telkins/feat/seer-night-shift-admin-overrides
Apr 16, 2026
Merged

feat(seer): Allow max candidate override on admin night shift trigger#113222
trevor-e merged 8 commits intomasterfrom
telkins/feat/seer-night-shift-admin-overrides

Conversation

@trevor-e
Copy link
Copy Markdown
Member

@trevor-e trevor-e commented Apr 16, 2026

Lets staff override the candidate cap from sentry.io/_admin/seer/ so testing the night shift flow no longer forces the full production batch.

  • run_night_shift_for_org and the admin trigger endpoint accept an optional max_candidates kwarg.
  • Cron path falls back to seer.night_shift.issues_per_org (now 10, was dormant — registered at 5 but the real cap was a hardcoded 10 in simple_triage.py).
  • Non-integer max_candidates returns 400.

Frontend PR #113223 adds the input to the admin page.

Add a triage strategy registry plus a new `seer.night_shift.default_strategy`
option so we can swap strategies (e.g. future `agentic_triage_v3`) without a
deploy. The cron resolves strategy and max_candidates from options; the admin
trigger endpoint can override both per-call for easier testing.

Also fix `seer.night_shift.issues_per_org`, which was dormant and drifting
(option default was 5, hardcoded cap was 10). The option is now actually read
and defaults to 10.

Admin endpoint validates unknown strategies (400) and clamps max_candidates
to [1, 50].
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 16, 2026
The clamp was defensive against accidental huge batches, but this is a
staff-only testing surface where silently rewriting the input is more
confusing than helpful. Non-integer values still 400.
Swapping the prod default strategy is a code-and-deploy operation in
practice; an options-automator knob is overkill for a single-entry
registry today. The per-call admin override is enough for testing,
and a future strategy change still updates DEFAULT_TRIAGE_STRATEGY.
Comment thread src/sentry/tasks/seer/night_shift/strategies.py Outdated
StrEnum keeps the registry/default wired to a single source of truth so
future strategy additions stop being magic-string edits. Values remain
plain strings at every boundary (HTTP, DB, logs).
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a626c6a. Configure here.

Comment thread src/sentry/seer/endpoints/admin_night_shift_trigger.py
With a single strategy today, the registry/enum/resolver is scaffolding
for a need that doesn't exist. Revert to calling agentic_triage_strategy
directly and keep only the max_candidates admin override, which is the
actual testing pain point. Multi-strategy support can be added in the
same PR that introduces the second strategy.
@trevor-e trevor-e changed the title feat(seer): Allow night shift strategy and max candidate overrides feat(seer): Allow max candidate override on admin night shift trigger Apr 16, 2026
Mirrors the admin endpoint override so local runs can test with a
smaller batch without twiddling the seer.night_shift.issues_per_org
option.
Without validation, a negative `max_candidates` hits Python slice
semantics in `fixability_score_strategy` (e.g. `candidates[:-1]` returns
all but the last), which processes far more candidates than intended.
Reject `< 1` at the admin endpoint (400) and in the CLI's argparse type.
@trevor-e trevor-e marked this pull request as ready for review April 16, 2026 20:34
@trevor-e trevor-e requested review from a team as code owners April 16, 2026 20:34
`x in (None, "")` doesn't narrow the type, so int(x) was flagged as
`Any | None` incompatible. Split into an explicit `is None` check.
@trevor-e trevor-e merged commit a7a207f into master Apr 16, 2026
77 checks passed
@trevor-e trevor-e deleted the telkins/feat/seer-night-shift-admin-overrides branch April 16, 2026 21:04
trevor-e added a commit that referenced this pull request Apr 16, 2026
Adds a max candidates input to sentry.io/_admin/seer/ so we can test the
night shift flow with a smaller batch than the production default.

- Number input (min 1). Leave blank to use the backend default.
- Value is omitted from the POST body when unset so the backend falls
back to `seer.night_shift.issues_per_org`.

Depends on backend PR #113222.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants