From ff451f0a6b0b2b68ec7922325a99b3207060b5ed Mon Sep 17 00:00:00 2001 From: Mihir-Mavalankar Date: Tue, 5 May 2026 15:36:49 -0700 Subject: [PATCH] feat(seer): Add event-specific LLM context hints for issue routes Extract getIssueDetailContextHint helper with three view modes: - issue-overview: default issue page with latest event - specific-event: user navigated to a specific event UUID, prompts the agent to fetch that event first - events-list: user is browsing all events for the issue Filter out pseudo-event IDs (latest/oldest/recommended) using RESERVED_EVENT_IDS so they don't trigger the specific-event hint. Register /issues/:groupId/events/ and /issues/:groupId/events/:eventId/ in NEW_STRUCTURED_CONTEXT_ROUTES behind the experimental flag. Co-Authored-By: Claude Opus 4.6 --- .../app/views/issueDetails/groupDetails.tsx | 52 ++++++++++++++++--- .../seerExplorer/hooks/useSeerExplorer.tsx | 5 +- 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/static/app/views/issueDetails/groupDetails.tsx b/static/app/views/issueDetails/groupDetails.tsx index dcdd98182d8331..ed9540f23dff42 100644 --- a/static/app/views/issueDetails/groupDetails.tsx +++ b/static/app/views/issueDetails/groupDetails.tsx @@ -72,7 +72,7 @@ import {Tab} from 'sentry/views/issueDetails/types'; import {useEngagedViewTracking} from 'sentry/views/issueDetails/useEngagedViewTracking'; import {groupApiOptions, useGroup} from 'sentry/views/issueDetails/useGroup'; import {useGroupDetailsRoute} from 'sentry/views/issueDetails/useGroupDetailsRoute'; -import {useGroupEvent} from 'sentry/views/issueDetails/useGroupEvent'; +import {RESERVED_EVENT_IDS, useGroupEvent} from 'sentry/views/issueDetails/useGroupEvent'; import { getGroupReprocessingStatus, markEventSeen, @@ -566,6 +566,40 @@ function GroupDetailsContentError({ } } +function getIssueDetailContextHint( + view: 'specific-event' | 'events-list' | 'issue-overview' +): string { + const tools = + 'Tools: get_issue_details(issue_id) for issue aggregate stats and stack trace; ' + + 'get_event_details(event_id?, issue_id?) for a specific error event; ' + + 'telemetry_live_search(dataset, question, project_slugs) for querying spans/errors/logs/metrics.'; + const shortIdNote = 'shortId is the human-readable issue identifier (e.g. PROJ-123). '; + + if (view === 'specific-event') { + return ( + 'Sentry issue detail page. The user is viewing a specific event — ' + + 'call get_event_details(event_id) with the eventId below to see what they see. ' + + shortIdNote + + tools + ); + } + + if (view === 'events-list') { + return ( + 'Sentry issue events list. The user is browsing all events for this issue. ' + + 'Use telemetry_live_search to query events matching this issue. ' + + shortIdNote + + tools + ); + } + + return ( + 'Sentry issue detail page. Shows a single grouped issue with its latest event. ' + + shortIdNote + + tools + ); +} + function GroupDetailsContentInner({ children, group, @@ -642,13 +676,17 @@ function GroupDetailsContentInner({ useEngagedViewTracking({group, project}); + const {eventId: eventIdParam} = useParams<{eventId?: string}>(); + + let issueView: 'specific-event' | 'events-list' | 'issue-overview' = 'issue-overview'; + if (eventIdParam && !RESERVED_EVENT_IDS.has(eventIdParam)) { + issueView = 'specific-event'; + } else if (currentTab === Tab.EVENTS) { + issueView = 'events-list'; + } + useLLMContext({ - contextHint: - 'Sentry issue detail page. Shows a single grouped issue with its latest event. ' + - 'shortId is the human-readable issue identifier (e.g. PROJ-123). ' + - 'Tools: get_issue_details(issue_id) for issue aggregate stats and stack trace; ' + - 'get_event_details(event_id?, issue_id?) for a specific error event; ' + - 'telemetry_live_search(dataset, question, project_slugs) for querying spans/errors/logs/metrics.', + contextHint: getIssueDetailContextHint(issueView), shortId: group.shortId, title: group.title, level: group.level, diff --git a/static/app/views/seerExplorer/hooks/useSeerExplorer.tsx b/static/app/views/seerExplorer/hooks/useSeerExplorer.tsx index 599cad113619e4..f753e4802cc516 100644 --- a/static/app/views/seerExplorer/hooks/useSeerExplorer.tsx +++ b/static/app/views/seerExplorer/hooks/useSeerExplorer.tsx @@ -57,7 +57,10 @@ const STRUCTURED_CONTEXT_ROUTES = new Set([ '/issues/:groupId/', ]); /** New experimental routes where the LLMContext tree provides structured page context. */ -const NEW_STRUCTURED_CONTEXT_ROUTES = new Set(); +const NEW_STRUCTURED_CONTEXT_ROUTES = new Set([ + '/issues/:groupId/events/', + '/issues/:groupId/events/:eventId/', +]); function supportsStructuredContext( referrer: string,