Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/sentry/investigations/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
MAX_TOOL_CONTENT_CHARS = 100_000
MAX_QUERY_LINK_PARAM_CHARS = 2000
IMPORT_NOT_ALLOWED_ERROR = "This import is not allowed in an investigation query."
SEER_CATEGORY_KEY = "investigation"
PRIVATE_TRANSCRIPT_KEYS = {
"authorization",
"credentials",
Expand Down Expand Up @@ -176,6 +177,8 @@ def start_execution_run(
if client is None:
client = SeerAgentClient(organization, user)
client.on_completion_hook = InvestigationAgentCompletionHook
client.category_key = SEER_CATEGORY_KEY
client.category_value = str(execution.block.investigation_id)
client.is_interactive = is_query
client.enable_code_mode_tools = "only" if is_query else "off"
client.enable_coding = False
Expand Down Expand Up @@ -980,6 +983,8 @@ def _maybe_start_title_generation(investigation: Investigation, user_id: int | N
client = SeerAgentClient(
investigation.organization,
user,
category_key=SEER_CATEGORY_KEY,
category_value=str(investigation.id),
on_completion_hook=InvestigationAgentCompletionHook,
enable_code_mode_tools="only",
enable_coding=False,
Expand Down
20 changes: 20 additions & 0 deletions tests/sentry/investigations/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,14 @@ def test_start_run_includes_resolved_source_context(self) -> None:
"2026-08-14T23:56:02+00:00"
)

def test_start_run_categorizes_the_run_as_an_investigation(self) -> None:
client = MagicMock()

start_execution_run(self.execution, self.organization, self.user, client)

assert client.category_key == "investigation"
assert client.category_value == str(self.investigation.id)

@patch("sentry.investigations.agent.record_execution_started")
def test_start_run_records_execution_started(self, record_started: MagicMock) -> None:
pending_execution = self.create_investigation_block_execution(
Expand Down Expand Up @@ -1177,6 +1185,18 @@ def test_title_prompt_uses_specific_incident_source_context(
assert "1 or 2 short" in prompt
assert "Avoid headings and jargon" in prompt

@patch("sentry.investigations.agent.SeerAgentClient")
def test_title_generation_categorizes_the_run_as_an_investigation(
self, mock_client: MagicMock
) -> None:
self.investigation.update(title=DEFAULT_INVESTIGATION_TITLE)

_maybe_start_title_generation(self.investigation, None)

kwargs = mock_client.call_args.kwargs
assert kwargs["category_key"] == "investigation"
assert kwargs["category_value"] == str(self.investigation.id)

@patch("sentry.investigations.agent.record_investigation_completed")
@patch("sentry.investigations.agent.SeerAgentClient")
def test_title_generation_waits_for_every_auto_run_block(
Expand Down
Loading