Skip to content

ref(seer): Unify Seer project settings update helper and add tuning and auto_create_pr fields#116352

Merged
srest2021 merged 6 commits into
masterfrom
srest2021/ref-update-settings-pt1
May 29, 2026
Merged

ref(seer): Unify Seer project settings update helper and add tuning and auto_create_pr fields#116352
srest2021 merged 6 commits into
masterfrom
srest2021/ref-update-settings-pt1

Conversation

@srest2021
Copy link
Copy Markdown
Member

@srest2021 srest2021 commented May 27, 2026

Consolidate update_seer_project_settings and bulk_update_seer_project_settings into a single function
that bulk deletes/creates project options across 1+ project ids. Also, strip seat-based business logic (stopping point → auto_create_pr syncing, tuning validation) out of the update helper and add tuning and auto_create_pr as update fields, so it becomes a pure write layer and can be used by other callsites.

Followups: #116356, #115962

Why:

By moving business logic out, other callsites can do updates without hidden side effects.

Other cleanups:

  • SeerProjectSettingsUpdate uses snake_case keys via CamelSnakeSerializer.
  • Add tuning to the project settings endpoints serializers (as opposed to consolidating tuning="off" into stopping_point="off"), again to make it easier to support legacy seer.
  • Endpoint returns autoCreatePr and automationTuning in response.
  • Stopping point syncs auto_create_pr automatically.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 27, 2026
Comment thread src/sentry/seer/similarity/utils.py Outdated
@srest2021 srest2021 changed the title ref(seer): unify update_seer_project_settings and add autoCreatePr/automationTuning ref(seer): Unify Seer project settings helper and add tuning and auto_create_pr fields May 27, 2026
@srest2021 srest2021 changed the title ref(seer): Unify Seer project settings helper and add tuning and auto_create_pr fields ref(seer): Unify Seer project settings update helper and add tuning and auto_create_pr fields May 27, 2026
automation_tuning = serializers.ChoiceField(
choices=[AutofixAutomationTuningSettings.OFF, AutofixAutomationTuningSettings.MEDIUM],
required=False,
)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's easier to keep stopping point and tuning as independent fields, so that we can support legacy seer which allows other tuning values besides "off" and "medium".

# Keep stopping point in sync with handoff auto_create_pr.
if "stopping_point" in data and "auto_create_pr" not in data:
data["auto_create_pr"] = data["stopping_point"] == AutofixStoppingPoint.OPEN_PR

Copy link
Copy Markdown
Member Author

@srest2021 srest2021 May 27, 2026

Choose a reason for hiding this comment

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

Here we keep auto_create_pr in sync with the stopping point before we pass the serializer data to update_seer_project_settings.

Comment thread src/sentry/seer/endpoints/project_seer_settings.py
Comment thread src/sentry/seer/endpoints/project_seer_settings.py
Copy link
Copy Markdown
Member

@JoshFerge JoshFerge left a comment

Choose a reason for hiding this comment

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

I'm finding it a bit difficult to review, as there are a few threads to follow in this PR

  • Consolidate update_seer_project_settings and bulk_update_seer_project_settings into a single function
  • Strip seat-based business logic
  • add tuning and auto_create_pr as update fields
  • SeerProjectSettingsUpdate uses snake_case keys via CamelSnakeSerializer.
  • Add tuning to the project settings endpoints serializers (as opposed to consolidating tuning="off" into stopping_point="off"), again to make it easier to support legacy seer.
  • Endpoint returns autoCreatePr and automationTuning in response.
  • Stopping point syncs auto_create_pr automatically.

Could this PR be broken down further, or do all these changes need to go in together?

@srest2021 srest2021 marked this pull request as draft May 28, 2026 22:24
@srest2021 srest2021 force-pushed the srest2021/ref-update-settings-pt1 branch from dc236fb to f682313 Compare May 28, 2026 22:24
@srest2021 srest2021 marked this pull request as ready for review May 28, 2026 22:32
Comment thread src/sentry/seer/autofix/utils.py Outdated
Comment thread src/sentry/seer/autofix/utils.py
Copy link
Copy Markdown
Member

@JoshFerge JoshFerge left a comment

Choose a reason for hiding this comment

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

looks great! appreciate breaking it out by commit, super easy to review! just a couple minor comments

@srest2021 srest2021 merged commit c8dc13c into master May 29, 2026
69 checks passed
@srest2021 srest2021 deleted the srest2021/ref-update-settings-pt1 branch May 29, 2026 17:05
srest2021 added a commit that referenced this pull request May 29, 2026
…ndpoint (#115962)

Depends on #116352 and
#116356.

Add legacy usage-based Seer support to the project settings endpoints by
branching on `is_seer_seat_based_tier_enabled`.

**Serializer split:**
- Extract `_BaseProjectSettingsUpdateSerializer` with shared validation
(agent, integration_id, cross-field checks)
- `ProjectSettingsUpdateSerializer` (seat-based): restricted tuning
choices (off/medium), stopping_point validation via
`get_valid_automated_run_stopping_points`, auto_create_pr synced from
stopping_point
- `LegacyProjectSettingsUpdateSerializer` (usage-based): accepts all
tuning values, direct `auto_create_pr` field, no stopping_point
restrictions

### Example payloads

**Set tuning to a granular value:**
```json
PUT /api/0/projects/{org}/{project}/seer/settings/
{"automationTuning": "high"}
```

**Set stopping point (frontend sends agent=seer to clear any external
handoff):**
```json
PUT /api/0/projects/{org}/{project}/seer/settings/
{"stoppingPoint": "code_changes", "agent": "seer"}
```
This clears handoff keys (target, point, integration_id) but preserves
`auto_create_pr` so switching back to an external agent restores the
previous toggle value.

**Switch to external agent with auto_create_pr:**
```json
PUT /api/0/projects/{org}/{project}/seer/settings/
{"agent": "cursor_background_agent", "integrationId": 1, "autoCreatePr": true}
```

**Toggle auto_create_pr on an existing external agent:**
```json
PUT /api/0/projects/{org}/{project}/seer/settings/
{"autoCreatePr": false}
```

**Turn off automation:**
```json
PUT /api/0/projects/{org}/{project}/seer/settings/
{"automationTuning": "off"}
```
GET response will show `stoppingPoint: "off"`, but the stored stopping
point is unchanged — re-enabling restores it.
srest2021 added a commit that referenced this pull request May 29, 2026
…t need to update the full Seer project preference (#116356)

Followup to #116352.

Reroute existing callsites that modify seer project settings
(`_write_preferences_to_sentry_db`, `configure_seer_for_existing_org`,
`set_default_project_seer_preferences`) to the unified
`update_seer_project_settings` helper. This ensures handoff options are
cleared/added atomically and skips unnecessary connected repo
operations.

Also remove `Project` row locks from `_write_preferences_to_sentry_db`
and `clear_preference_automation_handoff` — no longer needed since
handoff options are all either cleared or added atomically, and the
other update fields may be updated independently of each other.
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