Skip to content

feat(autofix): Push PR iteration changes and sync completion webhook#117220

Draft
joseph-sentry wants to merge 32 commits into
joey--autofix-pr-iteration-metricsfrom
joey--autofix-pr-iteration-hook-push
Draft

feat(autofix): Push PR iteration changes and sync completion webhook#117220
joseph-sentry wants to merge 32 commits into
joey--autofix-pr-iteration-metricsfrom
joey--autofix-pr-iteration-hook-push

Conversation

@joseph-sentry

@joseph-sentry joseph-sentry commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

When a PR iteration run finishes, the agent's new file patches still need
to be pushed to the existing PR. Trigger that push from the completion
hook so the PR is updated, and only emit the iteration completion webhook
on the synced pass so the payload reflects the updated PR and we don't
double-fire.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@github-actions github-actions Bot added Scope: Frontend Automatically applied to PRs that change frontend components Scope: Backend Automatically applied to PRs that change backend components labels Jun 9, 2026
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

@joseph-sentry joseph-sentry changed the title joey autofix pr iteration hook push feat(autofix): Push PR iteration changes and sync completion webhook Jun 9, 2026
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-hook-push branch from ba8fbbd to ece9167 Compare June 9, 2026 19:04
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-metrics branch 2 times, most recently from ba1ab28 to 30f8ee6 Compare June 10, 2026 20:25
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-hook-push branch from ece9167 to 95e2abc Compare June 10, 2026 20:25
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-metrics branch from 30f8ee6 to 61e5cd3 Compare June 12, 2026 14:10
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-hook-push branch 2 times, most recently from 2156fc1 to 95e2abc Compare June 12, 2026 15:21
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-metrics branch from 61e5cd3 to 30f8ee6 Compare June 12, 2026 15:21
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-hook-push branch from 95e2abc to aa2e40c Compare June 12, 2026 16:31
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-metrics branch from 30f8ee6 to 6491a12 Compare June 12, 2026 16:31
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-hook-push branch from aa2e40c to fa1434f Compare June 12, 2026 17:06
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-metrics branch 2 times, most recently from 3e64907 to 597ff23 Compare June 12, 2026 17:40
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-hook-push branch 2 times, most recently from 449edff to fc3e813 Compare June 12, 2026 19:48
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-metrics branch 2 times, most recently from a2a73f7 to 999e9ec Compare June 15, 2026 13:59
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-hook-push branch from fc3e813 to 1eb4a41 Compare June 15, 2026 13:59
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-metrics branch from 999e9ec to 30447ab Compare June 15, 2026 14:07
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-hook-push branch from 1eb4a41 to af07440 Compare June 15, 2026 14:07
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-metrics branch from 30447ab to f1c753c Compare June 15, 2026 14:51
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-hook-push branch from af07440 to 87f856e Compare June 15, 2026 14:51
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-metrics branch from f1c753c to 65c26eb Compare June 15, 2026 18:33
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-hook-push branch from 87f856e to 59f0a94 Compare June 15, 2026 18:33
@linear-code

linear-code Bot commented Jun 15, 2026

Copy link
Copy Markdown

CW-1399

joseph-sentry and others added 26 commits June 15, 2026 15:03
_hydrate_feedback_users assumed every block message carried a metadata
dict, but messages can have metadata set to null. Calling .get() on the
result crashed when hydrating feedback users. Coalesce metadata to an
empty dict before reading the feedback field.

Co-Authored-By: Claude <noreply@anthropic.com>
Patch get_autofix_run_state (not get_autofix_agent_state) in pr_iteration
tests, and add the feedback=None kwarg to trigger_autofix_agent call
assertions.
Send the ITERATION_COMPLETED webhook when a PR_ITERATION step finishes,
including the pull request payload, code changes, and iteration index, and
record the iteration index on the introspection analytics event. Add
introspect_iteration to evaluate whether revised iteration changes are ready
to update the existing pull request, and route PR_ITERATION through it. Extract
the pull-request and code-changes payload builders into shared helpers.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Accept the pr_iteration step in the explorer autofix endpoint, gated behind
the autofix-pr-iteration feature flag. The step requires an existing run with
at least one created pull request, otherwise it returns a 400. Map the
SEER_ITERATION_COMPLETED webhook to a SEER_ITERATION_COMPLETED group activity
in the operator, carrying the pull requests and iteration index.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Patch get_autofix_run_state (not get_autofix_agent_state) in pr_iteration
tests, and add the feedback=None kwarg to trigger_autofix_agent call
assertions.
Send the ITERATION_COMPLETED webhook when a PR_ITERATION step finishes,
including the pull request payload, code changes, and iteration index, and
record the iteration index on the introspection analytics event. Add
introspect_iteration to evaluate whether revised iteration changes are ready
to update the existing pull request, and route PR_ITERATION through it. Extract
the pull-request and code-changes payload builders into shared helpers.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Send the ITERATION_COMPLETED webhook when a PR_ITERATION step finishes,
including the pull request payload, code changes, and iteration index, and
record the iteration index on the introspection analytics event. Add
introspect_iteration to evaluate whether revised iteration changes are ready
to update the existing pull request, and route PR_ITERATION through it. Extract
the pull-request and code-changes payload builders into shared helpers.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Send the ITERATION_COMPLETED webhook when a PR_ITERATION step finishes,
including the pull request payload, code changes, and iteration index, and
record the iteration index on the introspection analytics event. Add
introspect_iteration to evaluate whether revised iteration changes are ready
to update the existing pull request, and route PR_ITERATION through it. Extract
the pull-request and code-changes payload builders into shared helpers.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Surface the PR iteration dimensions on the autofix analytics, metrics, and
logs so iteration runs can be segmented and correlated.

- Add pr_iteration_enabled to the AiAutofixPhaseEvent base so all phase
  events carry it, and populate it (plus iteration_index) on the started,
  completed, and introspection events.
- Tag the autofix.explorer.trigger and autofix.explorer.complete metrics
  with iteration_index and pr_iteration_enabled.
- Include both dimensions in the introspection, continuing_pipeline, and
  trigger webhook-failure logs.
- Extract an is_pr_iteration_enabled(state) helper to avoid repeating the
  metadata lookup across emission sites.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
we want to be able to trace through the execution of a given autofix
run via these events, if we don't have run_id then it's more difficult
Send the ITERATION_COMPLETED webhook when a PR_ITERATION step finishes,
including the pull request payload, code changes, and iteration index, and
record the iteration index on the introspection analytics event. Add
introspect_iteration to evaluate whether revised iteration changes are ready
to update the existing pull request, and route PR_ITERATION through it. Extract
the pull-request and code-changes payload builders into shared helpers.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Send the ITERATION_COMPLETED webhook when a PR_ITERATION step finishes,
including the pull request payload, code changes, and iteration index, and
record the iteration index on the introspection analytics event. Add
introspect_iteration to evaluate whether revised iteration changes are ready
to update the existing pull request, and route PR_ITERATION through it. Extract
the pull-request and code-changes payload builders into shared helpers.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
When a PR iteration run finishes, the agent's new file patches still need
to be pushed to the existing PR. Trigger that push from the completion
hook so the PR is updated, and only emit the iteration completion webhook
on the synced pass so the payload reflects the updated PR and we don't
double-fire.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-metrics branch from 65c26eb to b13daf5 Compare June 15, 2026 19:34
@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-hook-push branch from 59f0a94 to 1786047 Compare June 15, 2026 19:34
@github-actions

Copy link
Copy Markdown
Contributor

Backend Test Failures

Failures on 3d43f03 in this run:

tests/sentry/seer/autofix/test_autofix_on_completion_hook.py::TestAutofixOnCompletionHookWebhooks::test_send_step_webhook_pr_iterationlog
[gw0] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/seer/autofix/test_autofix_on_completion_hook.py:483: in test_send_step_webhook_pr_iteration
    mock_broadcast.assert_called_once()
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:956: in assert_called_once
    raise AssertionError(msg)
E   AssertionError: Expected 'delay' to have been called once. Called 0 times.
tests/sentry/seer/autofix/test_autofix_on_completion_hook.py::TestAutofixOnCompletionHookWebhooks::test_send_step_webhook_pr_iteration_does_not_emit_pr_createdlog
[gw0] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/seer/autofix/test_autofix_on_completion_hook.py:518: in test_send_step_webhook_pr_iteration_does_not_emit_pr_created
    mock_broadcast.call_args.kwargs["event_name"]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E   AttributeError: 'NoneType' object has no attribute 'kwargs'

@joseph-sentry joseph-sentry force-pushed the joey--autofix-pr-iteration-metrics branch from b13daf5 to ce32e64 Compare June 16, 2026 15:40
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 Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant