Skip to content

Commit b7e8d18

Browse files
isaacwang-sentryclaudecursoragent
authored
feat(assisted-query): Add metrics search feature flag and forward options (#112240)
## Summary - Register `gen-ai-explore-metrics-search` feature flag to gate the metrics AI search bar independently - Update `SearchAgentStartEndpoint` to accept the new flag when strategy is "Metrics" - Forward the full `options` dict to Seer instead of extracting only `model_name`, so strategy-specific context (like `metric_context`) passes through ## Test plan - [ ] Verify the `gen-ai-explore-metrics-search` flag is registered and exposed to the frontend - [ ] Verify the endpoint accepts requests with `strategy: "Metrics"` when the new flag is enabled - [ ] Verify the full `options` dict is forwarded to Seer --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 018fdaa commit b7e8d18

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

src/sentry/features/temporary.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ def register_temporary_features(manager: FeatureManager) -> None:
126126
manager.add("organizations:gen-ai-features", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True)
127127
# Enable the 'translate' functionality for GenAI on the explore > traces page
128128
manager.add("organizations:gen-ai-search-agent-translate", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True)
129+
# Enable AI search bar on the explore > metrics tab
130+
manager.add("organizations:gen-ai-explore-metrics-search", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True)
129131
# Enable GenAI consent
130132
manager.add("organizations:gen-ai-consent", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True)
131133
# Enable increased issue_owners rate limit for auto-assignment

src/sentry/seer/endpoints/search_agent_start.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def send_search_agent_start_request(
6767
user_email: str | None = None,
6868
timezone: str | None = None,
6969
model_name: str | None = None,
70+
metric_context: dict[str, Any] | None = None,
7071
viewer_context: SeerViewerContext | None = None,
7172
) -> dict[str, Any]:
7273
"""
@@ -87,6 +88,8 @@ def send_search_agent_start_request(
8788
options: dict[str, Any] = {}
8889
if model_name is not None:
8990
options["model_name"] = model_name
91+
if metric_context is not None:
92+
options["metric_context"] = metric_context
9093
if options:
9194
body["options"] = options
9295

@@ -129,15 +132,23 @@ def post(self, request: Request, organization: Organization) -> Response:
129132
strategy = validated_data.get("strategy", "Traces")
130133
options = validated_data.get("options") or {}
131134
model_name = options.get("model_name")
135+
metric_context = options.get("metric_context")
132136

133137
projects = self.get_projects(
134138
request, organization, project_ids=set(validated_data["project_ids"])
135139
)
136140
project_ids = [project.id for project in projects]
137141

138-
if not features.has(
142+
has_feature = features.has(
139143
"organizations:gen-ai-search-agent-translate", organization, actor=request.user
140-
):
144+
)
145+
if strategy == "Metrics":
146+
has_feature = has_feature and features.has(
147+
"organizations:gen-ai-explore-metrics-search",
148+
organization,
149+
actor=request.user,
150+
)
151+
if not has_feature:
141152
return Response(
142153
{"detail": "Feature flag not enabled"},
143154
status=status.HTTP_403_FORBIDDEN,
@@ -174,6 +185,7 @@ def post(self, request: Request, organization: Organization) -> Response:
174185
user_email=user_email,
175186
timezone=timezone,
176187
model_name=model_name,
188+
metric_context=metric_context,
177189
viewer_context=viewer_context,
178190
)
179191

src/sentry/seer/endpoints/search_agent_state.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,12 @@ def get(self, request: Request, organization: Organization, run_id: str) -> Resp
8181
}
8282
}
8383
"""
84-
if not features.has(
84+
has_feature = features.has(
8585
"organizations:gen-ai-search-agent-translate", organization, actor=request.user
86-
):
86+
) or features.has(
87+
"organizations:gen-ai-explore-metrics-search", organization, actor=request.user
88+
)
89+
if not has_feature:
8790
return Response(
8891
{"detail": "Feature flag not enabled"},
8992
status=status.HTTP_403_FORBIDDEN,

0 commit comments

Comments
 (0)