Skip to content

feat(autofix): Thread insert_index through explorer API for step retry#112287

Merged
isaacwang-sentry merged 5 commits intomasterfrom
isaacwang-sentry/feat/autofix-retry-from-step-flag
Apr 7, 2026
Merged

feat(autofix): Thread insert_index through explorer API for step retry#112287
isaacwang-sentry merged 5 commits intomasterfrom
isaacwang-sentry/feat/autofix-retry-from-step-flag

Conversation

@isaacwang-sentry
Copy link
Copy Markdown
Member

@isaacwang-sentry isaacwang-sentry commented Apr 6, 2026

Thread insert_index through the explorer autofix API so the frontend can request
a retry-from-step that truncates all downstream blocks. When provided, Seer does
blocks = blocks[:insert_index] before re-running the step, ensuring downstream
sections (e.g. Code Changes after retrying Plan) are properly removed.

Changes:

  • Add insert_index field to ExplorerAutofixRequestSerializer
  • Pass it through trigger_autofix_explorer()client.continue_run()

A follow-up frontend PR (#112290) adds retry buttons that use this parameter.

Add a new Flagpole feature flag to gate "Retry from step" buttons on
Autofix v3 cards. This is primarily useful for local Seer testing,
allowing developers to re-run individual autofix steps without
restarting the entire flow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pass insert_index from the API serializer through
trigger_autofix_explorer to client.continue_run. When provided,
Seer truncates blocks after that index, enabling retry-from-step
to properly reset downstream steps.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

Backend Test Failures

Failures on cfd5f3c in this run:

tests/sentry/seer/endpoints/test_group_ai_autofix.py::GroupAutofixEndpointExplorerRoutingTest::test_stopping_pointlog
[gw0] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/seer/endpoints/test_group_ai_autofix.py:935: in test_stopping_point
    mock_trigger_explorer.assert_called_once_with(
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:989: in assert_called_once_with
    return self.assert_called_with(*args, **kwargs)
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:977: in assert_called_with
    raise AssertionError(_error_message()) from cause
E   AssertionError: expected call not found.
E   Expected: trigger_autofix_explorer(group=<Group at 0x7fbd0791b610: id=37, project_id=4557923403431952>, step=<AutofixStep.ROOT_CAUSE: 'root_cause'>, referrer=<AutofixReferrer.GROUP_AUTOFIX_ENDPOINT: 'api.group_ai_autofix'>, stopping_point=<AutofixStoppingPoint.CODE_CHANGES: 'code_changes'>, run_id=None, intelligence_level='low', user_context=None)
E     Actual: trigger_autofix_explorer(group=<Group at 0x7fbd07928050: id=37, project_id=4557923403431952>, step=<AutofixStep.ROOT_CAUSE: 'root_cause'>, referrer=<AutofixReferrer.GROUP_AUTOFIX_ENDPOINT: 'api.group_ai_autofix'>, stopping_point=<AutofixStoppingPoint.CODE_CHANGES: 'code_changes'>, run_id=None, intelligence_level='low', user_context=None, insert_index=None)

The retry buttons are no longer gated behind a feature flag, so
this registration is unnecessary.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@isaacwang-sentry isaacwang-sentry changed the title feat(autofix): Register autofix-retry-from-step feature flag feat(autofix): Thread insert_index through explorer API for step retry Apr 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

Backend Test Failures

Failures on 45bbb05 in this run:

tests/sentry/seer/endpoints/test_group_ai_autofix.py::GroupAutofixEndpointExplorerRoutingTest::test_stopping_pointlog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/seer/endpoints/test_group_ai_autofix.py:935: in test_stopping_point
    mock_trigger_explorer.assert_called_once_with(
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:989: in assert_called_once_with
    return self.assert_called_with(*args, **kwargs)
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:977: in assert_called_with
    raise AssertionError(_error_message()) from cause
E   AssertionError: expected call not found.
E   Expected: trigger_autofix_explorer(group=<Group at 0x7f8f7b9dde50: id=37, project_id=4557923479978016>, step=<AutofixStep.ROOT_CAUSE: 'root_cause'>, referrer=<AutofixReferrer.GROUP_AUTOFIX_ENDPOINT: 'api.group_ai_autofix'>, stopping_point=<AutofixStoppingPoint.CODE_CHANGES: 'code_changes'>, run_id=None, intelligence_level='low', user_context=None)
E     Actual: trigger_autofix_explorer(group=<Group at 0x7f8f7b9dca50: id=37, project_id=4557923479978016>, step=<AutofixStep.ROOT_CAUSE: 'root_cause'>, referrer=<AutofixReferrer.GROUP_AUTOFIX_ENDPOINT: 'api.group_ai_autofix'>, stopping_point=<AutofixStoppingPoint.CODE_CHANGES: 'code_changes'>, run_id=None, intelligence_level='low', user_context=None, insert_index=None)

The test_stopping_point test checks exact kwargs passed to
trigger_autofix_explorer. Add the new insert_index=None parameter
to match the updated function signature.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@isaacwang-sentry isaacwang-sentry marked this pull request as ready for review April 7, 2026 18:41
@isaacwang-sentry isaacwang-sentry requested a review from a team as a code owner April 7, 2026 18:41
Verify that insert_index from the POST request is threaded through
to trigger_autofix_explorer for retry-from-step functionality.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f299f7a. Configure here.

prompt_metadata=prompt_metadata,
artifact_key=artifact_key,
artifact_schema=artifact_schema,
insert_index=insert_index,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

insert_index silently ignored when run_id is absent

Low Severity

When a caller provides insert_index without run_id, the parameter is silently dropped because trigger_autofix_explorer only passes insert_index to client.continue_run() in the else branch (existing run), not to client.start_run(). The endpoint has no validation to reject this combination — unlike open_pr and coding_agent_handoff, which explicitly check that run_id is present. A retry-from-step request missing run_id would quietly start a brand-new run instead of truncating and retrying.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f299f7a. Configure here.

@isaacwang-sentry isaacwang-sentry merged commit 977cb0f into master Apr 7, 2026
56 checks passed
@isaacwang-sentry isaacwang-sentry deleted the isaacwang-sentry/feat/autofix-retry-from-step-flag branch April 7, 2026 22:37
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.

2 participants