Skip to content
Merged
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
4 changes: 1 addition & 3 deletions src/sentry/seer/autofix/autofix_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,7 @@ def trigger_coding_agent_handoff(
)
state = client.get_run(run_id)

short_id = None
if auto_create_pr:
short_id = group.qualified_short_id
short_id = group.qualified_short_id

prompt = generate_autofix_handoff_prompt(state, short_id=short_id)

Expand Down
53 changes: 0 additions & 53 deletions tests/sentry/seer/autofix/test_autofix_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,56 +543,3 @@ def test_trigger_coding_agent_handoff_no_preferences_returns_failure(
assert len(result["failures"]) == 1
assert "No repositories configured" in result["failures"][0]["error_message"]
mock_client.launch_coding_agents.assert_not_called()

@patch("sentry.seer.autofix.autofix_agent.get_project_seer_preferences")
@patch("sentry.seer.autofix.autofix_agent.SeerExplorerClient")
def test_trigger_coding_agent_handoff_includes_short_id_when_auto_create_pr_enabled(
self, mock_client_class, mock_get_prefs
):
"""Test that short_id is included in prompt when auto_create_pr is True."""
mock_client = MagicMock()
mock_client_class.return_value = mock_client
mock_client.get_run.return_value = self._make_run_state()
mock_client.launch_coding_agents.return_value = {"successes": [], "failures": []}

# Set up preferences with auto_create_pr=True
mock_get_prefs.return_value = self._make_preference_response(auto_create_pr=True)

trigger_coding_agent_handoff(
group=self.group,
run_id=123,
integration_id=456,
)

call_kwargs = mock_client.launch_coding_agents.call_args.kwargs
prompt = call_kwargs["prompt"]
# Prompt should contain "Fixes {short_id}" instruction
assert (
f"Include 'Fixes {self.group.qualified_short_id}' in the pull request description"
in prompt
)

@patch("sentry.seer.autofix.autofix_agent.get_project_seer_preferences")
@patch("sentry.seer.autofix.autofix_agent.SeerExplorerClient")
def test_trigger_coding_agent_handoff_excludes_short_id_when_auto_create_pr_disabled(
self, mock_client_class, mock_get_prefs
):
"""Test that short_id is NOT included in prompt when auto_create_pr is False."""
mock_client = MagicMock()
mock_client_class.return_value = mock_client
mock_client.get_run.return_value = self._make_run_state()
mock_client.launch_coding_agents.return_value = {"successes": [], "failures": []}

# Set up preferences with auto_create_pr=False (default)
mock_get_prefs.return_value = self._make_preference_response(auto_create_pr=False)

trigger_coding_agent_handoff(
group=self.group,
run_id=123,
integration_id=456,
)

call_kwargs = mock_client.launch_coding_agents.call_args.kwargs
prompt = call_kwargs["prompt"]
# Prompt should NOT contain "Fixes" instruction
assert "Fixes" not in prompt
Loading