Skip to content

Conversation

@roaga
Copy link
Member

@roaga roaga commented Nov 24, 2025

Sends an is_interactive flag in the client. Defaults to False, but sets to True for the UI chat endpoint.

Part of AIML-1689: indicator on state whether on Sentry UI or not

Copy link
Member Author

roaga commented Nov 24, 2025

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 24, 2025
@roaga roaga marked this pull request as ready for review November 24, 2025 22:23
@roaga roaga requested a review from a team as a code owner November 24, 2025 22:23
Copy link
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.

Bug: Missing is_interactive flag in continue_run payload

The continue_run method doesn't include is_interactive in its payload, unlike start_run which sends it on line 166. When users continue a conversation from the UI chat endpoint, the continuation requests won't be marked as interactive, causing inconsistent behavior where only the first message in a conversation is flagged as interactive while follow-ups are not, despite all interactions occurring on the Sentry UI.

src/sentry/seer/explorer/client.py#L197-L230

def continue_run(
self,
run_id: int,
prompt: str,
insert_index: int | None = None,
on_page_context: str | None = None,
) -> int:
"""
Continue an existing Seer Explorer session. This allows you to add follow-up queries to an ongoing conversation.
Args:
run_id: The run ID from start_run()
prompt: The follow-up task/query for the agent
insert_index: Optional index to insert the message at
on_page_context: Optional context from the user's screen
Returns:
int: The run ID (same as input)
Raises:
requests.HTTPError: If the Seer API request fails
"""
path = "/v1/automation/explorer/chat"
payload: dict[str, Any] = {
"organization_id": self.organization.id,
"query": prompt,
"run_id": run_id,
"insert_index": insert_index,
"on_page_context": on_page_context,
}
body = orjson.dumps(payload, option=orjson.OPT_NON_STR_KEYS)

Fix in Cursor Fix in Web


@roaga roaga requested a review from aliu39 November 24, 2025 22:36
@codecov
Copy link

codecov bot commented Nov 24, 2025

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
30017 2 30015 239
View the top 2 failed test(s) by shortest run time
tests.sentry.seer.endpoints.test_organization_seer_explorer_chat.OrganizationSeerExplorerChatEndpointTest::test_post_new_conversation_calls_client
Stack Traces | 1.41s run time
#x1B[1m#x1B[.../seer/endpoints/test_organization_seer_explorer_chat.py#x1B[0m:72: in test_post_new_conversation_calls_client
    mock_client_class.assert_called_once_with(self.organization, ANY)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1....../x64/lib/python3.13/unittest/mock.py#x1B[0m:989: in assert_called_once_with
    return self.assert_called_with(*args, **kwargs)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1....../x64/lib/python3.13/unittest/mock.py#x1B[0m:977: in assert_called_with
    raise AssertionError(_error_message()) from cause
#x1B[1m#x1B[31mE   AssertionError: expected call not found.#x1B[0m
#x1B[1m#x1B[31mE   Expected: SeerExplorerClient(<Organization at 0x7f3898f447e0: id=4557170394857472, owner_id=None, name='baz', slug='baz'>, <ANY>)#x1B[0m
#x1B[1m#x1B[31mE     Actual: SeerExplorerClient(<Organization at 0x7f3898f44cb0: id=4557170394857472, owner_id=None, name='baz', slug='baz'>, <SimpleLazyObject: RpcUser(id=732, pk=732, name='', email='admin@localhost', username='admin@localhost', actor_id=None, display_name='admin@localhost', label='admin@localhost', is_superuser=True, is_authenticated=True, is_anonymous=False, is_active=True, is_staff=True, is_unclaimed=False, last_active=datetime.datetime(2025, 11, 24, 22, 30, 41, 944401, tzinfo=datetime.timezone.utc), is_sentry_app=False, password_usable=True, is_password_expired=False, session_nonce=None, roles=frozenset(), permissions=frozenset(), avatar=None, emails=frozenset({'admin@localhost'}), useremails=[RpcUserEmail(id=734, email='admin@localhost', is_verified=True)], authenticators=[])>, is_interactive=True)#x1B[0m
tests.sentry.seer.endpoints.test_organization_seer_explorer_chat.OrganizationSeerExplorerChatEndpointTest::test_post_continue_conversation_calls_client
Stack Traces | 1.64s run time
#x1B[1m#x1B[.../seer/endpoints/test_organization_seer_explorer_chat.py#x1B[0m:93: in test_post_continue_conversation_calls_client
    mock_client_class.assert_called_once_with(self.organization, ANY)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1....../x64/lib/python3.13/unittest/mock.py#x1B[0m:989: in assert_called_once_with
    return self.assert_called_with(*args, **kwargs)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1....../x64/lib/python3.13/unittest/mock.py#x1B[0m:977: in assert_called_with
    raise AssertionError(_error_message()) from cause
#x1B[1m#x1B[31mE   AssertionError: expected call not found.#x1B[0m
#x1B[1m#x1B[31mE   Expected: SeerExplorerClient(<Organization at 0x7f3cc0341130: id=4557170400231424, owner_id=None, name='baz', slug='baz'>, <ANY>)#x1B[0m
#x1B[1m#x1B[31mE     Actual: SeerExplorerClient(<Organization at 0x7f3cb8f96170: id=4557170400231424, owner_id=None, name='baz', slug='baz'>, <SimpleLazyObject: RpcUser(id=746, pk=746, name='', email='admin@localhost', username='admin@localhost', actor_id=None, display_name='admin@localhost', label='admin@localhost', is_superuser=True, is_authenticated=True, is_anonymous=False, is_active=True, is_staff=True, is_unclaimed=False, last_active=datetime.datetime(2025, 11, 24, 22, 32, 3, 964261, tzinfo=datetime.timezone.utc), is_sentry_app=False, password_usable=True, is_password_expired=False, session_nonce=None, roles=frozenset(), permissions=frozenset(), avatar=None, emails=frozenset({'admin@localhost'}), useremails=[RpcUserEmail(id=758, email='admin@localhost', is_verified=True)], authenticators=[])>, is_interactive=True)#x1B[0m

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Copy link
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.

Bug: `is_interactive` flag missing from `continue_run` payload

The is_interactive flag is added to the start_run payload but is missing from the continue_run payload. When a conversation is continued through the UI chat endpoint (which sets is_interactive=True on the client), the continue_run method won't send this flag to the Seer API. The stored self.is_interactive value needs to be included in the continue_run payload for consistent behavior between new and continued conversations.

src/sentry/seer/explorer/client.py#L221-L228

payload: dict[str, Any] = {
"organization_id": self.organization.id,
"query": prompt,
"run_id": run_id,
"insert_index": insert_index,
"on_page_context": on_page_context,
}

Fix in Cursor Fix in Web


Comment on lines 163 to 169
"on_page_context": on_page_context,
"user_org_context": collect_user_org_context(self.user, self.organization),
"intelligence_level": self.intelligence_level,
"is_interactive": self.is_interactive,
}

# Add artifact schema if provided

This comment was marked as outdated.

Copy link
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.

Bug: Missing `is_interactive` flag in continue_run payload

The is_interactive flag is added to the start_run payload but not to the continue_run payload. When the UI chat endpoint continues an existing conversation via continue_run, the is_interactive=True setting stored in self.is_interactive is never sent to the Seer backend. This means follow-up messages in interactive conversations won't receive the full interactive treatment intended by this feature.

src/sentry/seer/explorer/client.py#L221-L228

payload: dict[str, Any] = {
"organization_id": self.organization.id,
"query": prompt,
"run_id": run_id,
"insert_index": insert_index,
"on_page_context": on_page_context,
}

src/sentry/seer/explorer/client.py#L165-L166

"intelligence_level": self.intelligence_level,
"is_interactive": self.is_interactive,

Fix in Cursor Fix in Web


@roaga roaga merged commit 8e631f2 into master Nov 25, 2025
66 checks passed
@roaga roaga deleted the explorer/track-interactive-state-client branch November 25, 2025 00:26
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.

3 participants