-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat(seer): Add org-level default stopping point and wire coding agent defaults into project creation #111697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
42b9053
007a027
52fb592
91b53a8
83f31ca
3564251
b14d154
22f98fe
7a0759f
684ac29
88d4106
df1f39e
99b0f5f
33bc6b2
f745023
5bb23fd
e5508b9
e9a9725
82b453a
8138f6c
1150293
2e5a937
ab215d0
53c106c
d7e7df5
adeb0c8
e236a23
6c3c62d
ac7e0da
e210c94
cb71151
d6bddbe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,7 @@ | |
| ROLLBACK_ENABLED_DEFAULT, | ||
| SAMPLING_MODE_DEFAULT, | ||
| SCRAPE_JAVASCRIPT_DEFAULT, | ||
| SEER_AUTOMATED_RUN_STOPPING_POINT_DEFAULT, | ||
| SEER_DEFAULT_CODING_AGENT_DEFAULT, | ||
| TARGET_SAMPLE_RATE_DEFAULT, | ||
| ObjectStatus, | ||
|
|
@@ -254,12 +255,17 @@ | |
| None, | ||
| ), | ||
| ( | ||
| # Informs UI default for automated_run_stopping_point in project preferences | ||
| "autoOpenPrs", | ||
| "sentry:auto_open_prs", | ||
| bool, | ||
| AUTO_OPEN_PRS_DEFAULT, | ||
| ), | ||
| ( | ||
| "defaultAutomatedRunStoppingPoint", | ||
| "sentry:default_automated_run_stopping_point", | ||
srest2021 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| str, | ||
| SEER_AUTOMATED_RUN_STOPPING_POINT_DEFAULT, | ||
| ), | ||
| ( | ||
| "autoEnableCodeReview", | ||
| "sentry:auto_enable_code_review", | ||
|
|
@@ -371,8 +377,15 @@ class OrganizationSerializer(BaseOrganizationSerializer): | |
| dashboardsAsyncQueueParallelLimit = serializers.IntegerField(required=False, min_value=1) | ||
| enableSeerEnhancedAlerts = serializers.BooleanField(required=False) | ||
| enableSeerCoding = serializers.BooleanField(required=False) | ||
| defaultCodingAgent = serializers.CharField(required=False, allow_null=True) | ||
| defaultCodingAgent = serializers.ChoiceField( | ||
| choices=["seer", "cursor", "claude_code", "cursor_background_agent", "claude_code_agent"], | ||
| required=False, | ||
| allow_null=True, | ||
| ) | ||
| defaultCodingAgentIntegrationId = serializers.IntegerField(required=False, allow_null=True) | ||
| defaultAutomatedRunStoppingPoint = serializers.ChoiceField( | ||
| choices=["code_changes", "open_pr"], required=False | ||
| ) | ||
srest2021 marked this conversation as resolved.
Show resolved
Hide resolved
srest2021 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| autoOpenPrs = serializers.BooleanField(required=False) | ||
| autoEnableCodeReview = serializers.BooleanField(required=False) | ||
| defaultCodeReviewTriggers = serializers.ListField( | ||
|
|
@@ -401,6 +414,15 @@ def validate_relayPiiConfig(self, value): | |
| organization = self.context["organization"] | ||
| return validate_pii_config_update(organization, value) | ||
|
|
||
| def validate_defaultCodingAgent(self, value: str | None) -> str: | ||
| if value is None: | ||
| return SEER_DEFAULT_CODING_AGENT_DEFAULT | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normalize None to "seer" so that we always have an explicit default coding agent |
||
| coding_agent_aliases: dict[str, str] = { | ||
| "cursor": "cursor_background_agent", | ||
| "claude_code": "claude_code_agent", | ||
| } | ||
|
Comment on lines
+420
to
+423
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| return coding_agent_aliases.get(value, value) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| def validate_defaultCodingAgentIntegrationId(self, value: int | None) -> int | None: | ||
| if value is None: | ||
| return None | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,9 @@ | |
|
|
||
| from sentry import analytics, features | ||
| from sentry.analytics.events.autofix_automation_events import AiAutofixAutomationEvent | ||
| from sentry.constants import ObjectStatus | ||
| from sentry.constants import ( | ||
| ObjectStatus, | ||
| ) | ||
| from sentry.models.group import Group | ||
| from sentry.models.organization import Organization | ||
| from sentry.models.project import Project | ||
|
|
@@ -24,6 +26,7 @@ | |
| deduplicate_repositories, | ||
| get_autofix_repos_from_project_code_mappings, | ||
| get_autofix_state, | ||
| get_org_default_seer_automation_handoff, | ||
| get_seer_seat_based_tier_cache_key, | ||
| resolve_repository_ids, | ||
| ) | ||
|
|
@@ -238,34 +241,49 @@ def configure_seer_for_existing_org(organization_id: int) -> None: | |
| "sentry:autofix_automation_tuning", AutofixAutomationTuningSettings.MEDIUM | ||
| ) | ||
|
|
||
| default_stopping_point, default_handoff = get_org_default_seer_automation_handoff(organization) | ||
| default_handoff_dict = default_handoff.dict() if default_handoff else None | ||
|
|
||
| valid_stopping_points = {"open_pr", "code_changes"} | ||
|
|
||
| preferences_by_id = bulk_get_project_preferences(organization_id, project_ids) | ||
|
|
||
| # Determine which projects need updates | ||
| preferences_to_set = [] | ||
| projects_by_id = {p.id: p for p in projects} | ||
| for project_id in project_ids: | ||
| stopping_point = default_stopping_point | ||
| handoff = default_handoff_dict | ||
|
|
||
| existing_pref = preferences_by_id.get(str(project_id)) | ||
| if not existing_pref: | ||
| # No existing preferences, get repositories from code mappings | ||
| repositories = get_autofix_repos_from_project_code_mappings(projects_by_id[project_id]) | ||
| else: | ||
| # Skip projects that already have an acceptable stopping point configured | ||
| if existing_pref.get("automated_run_stopping_point") in ("open_pr", "code_changes"): | ||
| continue | ||
| repositories = existing_pref.get("repositories") or [] | ||
|
|
||
| repositories = deduplicate_repositories(repositories) | ||
| existing_stopping_point = existing_pref.get("automated_run_stopping_point") | ||
| existing_handoff = existing_pref.get("automation_handoff") | ||
|
|
||
| # Skip projects that a) already have an acceptable stopping point configured | ||
| # AND b) already have a handoff configured or no org default handoff. | ||
| if existing_stopping_point in valid_stopping_points and ( | ||
| existing_handoff or default_handoff_dict is None | ||
| ): | ||
| continue | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Mihir-Mavalankar Fixed the |
||
|
|
||
| if existing_stopping_point in valid_stopping_points: | ||
| stopping_point = existing_stopping_point | ||
| if existing_handoff: | ||
| handoff = existing_handoff | ||
|
|
||
| # Preserve existing repositories and automation_handoff, only update the stopping point | ||
| preferences_to_set.append( | ||
| { | ||
| "organization_id": organization_id, | ||
| "project_id": project_id, | ||
sentry[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "repositories": repositories or [], | ||
| "automated_run_stopping_point": "code_changes", | ||
| "automation_handoff": ( | ||
| existing_pref.get("automation_handoff") if existing_pref else None | ||
| ), | ||
| "repositories": deduplicate_repositories(repositories) or [], | ||
| "automated_run_stopping_point": stopping_point, | ||
| "automation_handoff": handoff, | ||
| } | ||
| ) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.