Skip to content

fix(seer): Keep one failed Seer Agent reply edit from blocking the rest - #128808

Merged
joseph-sentry merged 6 commits into
masterfrom
joey--slack-agent-reply-edit-errors
Nov 5, 2026
Merged

joseph-sentry merged 6 commits into
masterfrom
joey--slack-agent-reply-edit-errors

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Follows up on @billyvg's review of #127881.

Before this change, edit_thread_message called chat.update without a lifecycle or error handling. So when one answer's edit failed (for example, message_not_found after someone deleted the message), the error left the loop before the later answers were edited. That answer's pr_status_hash was never updated, so every later refresh failed on the same edit, and the latest answer's footer could stay on "Creating a PR in …".

What changed:

  • edit_thread_message now runs inside its own SlackEntrypointEventLifecycleMetric (edit_thread_message).
  • A missing message or channel (message_not_found, channel_not_found, is_archived) ends the edit. SlackIntegration.update_message raises IntegrationResourceNotFoundError for these, edit_thread_message records a halt and returns, and on_agent_update caches the new hash so later refreshes don't call chat.update on that reply again.
  • Every other Slack error still raises, so refresh_agent_run retries the edit. Halt categories that can clear, like ratelimited or internal_error, are recorded as halts and raised. Other errors are recorded as failures and raised. A timeout is raised as IntegrationError.
  • on_agent_update catches edit errors one message at a time. It still edits and caches the remaining answers, then raises the first error so the refresh retries only the edits that failed.
  • Billy also asked when send_thread_update returns no message_ts. In practice that's a halt, which its lifecycle already records, but the record didn't say which run it was for. on_agent_update now logs seer.entrypoint.slack.agent_update.reply_not_posted with the run id and reply key. A halted post isn't retried: send_thread_update doesn't raise, so the reply waits for the run's next Seer completion hook. Retrying transient post halts would change send_thread_update, which process_thread_update and on_trigger_agent_error also use, so it's left out of this PR.

The shared SLACK_SDK_HALT_ERROR_CATEGORIES list is unchanged. message_not_found is now a recognized category, and only update_message treats it, along with the channel errors, as not found. Its other callers catch IntegrationError, which IntegrationResourceNotFoundError subclasses, so they still record a halt.

One test runs refreshes until nothing is left to edit. It covers a rate-limited edit that's retried without blocking the next answer, and a deleted message that halts once and isn't edited again. The reply_not_posted log has no test.

--

View Session [Sentry]

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 26, 2026
Base automatically changed from joey--slack-create-pr-stacked to master October 26, 2026 19:26
@joseph-sentry
joseph-sentry force-pushed the joey--slack-agent-reply-edit-errors branch from 78ecc5e to ed6e16e Compare October 26, 2026 19:26
@joseph-sentry

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment

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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit ed6e16e. Configure here.

@sentry-junior
sentry-junior Bot requested review from billyvg and leeandher October 26, 2026 19:34
@sentry-junior
sentry-junior Bot marked this pull request as ready for review October 26, 2026 19:34
@sentry-junior
sentry-junior Bot requested review from a team as code owners October 26, 2026 19:34

@billyvg billyvg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🤖 AI-assisted review, posted on behalf of @billyvg.

@joseph-sentry
joseph-sentry requested a review from billyvg November 3, 2026 15:18

@billyvg billyvg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🤖 AI-assisted review, posted on behalf of @billyvg.

sentry-junior Bot and others added 6 commits November 3, 2026 16:46
Editing a posted Seer Agent answer now goes through its own lifecycle, like send_thread_update. Halt-category Slack errors and a deleted message (message_not_found) are recorded as halts instead of being raised for task retries. Other edit failures no longer stop the loop: the remaining answers are still edited and cached, then the first error is raised so the refresh retries only what failed. A reply that didn't post now logs its run and reply key.

Refs CW-2180
…ng it

Adding it to SLACK_SDK_HALT_ERROR_CATEGORIES makes translate_slack_api_error raise IntegrationConfigurationError, so edit_thread_message's existing halt branch covers deleted messages without an inline import or message comparison.

Refs CW-2180
…replies

Only a missing message or channel ends a Seer Agent reply edit. Slack's update_message now raises IntegrationResourceNotFoundError for message_not_found, channel_not_found and is_archived, and on_agent_update caches the new hash so later refreshes skip the reply. Other halt categories, like ratelimited, are still recorded as halts but raised so refresh_agent_run retries the edit. message_not_found is no longer in the shared halt list.

Refs CW-2180
Replace the three edit-error tests with one test that runs refreshes until nothing is left to edit. A rate-limited edit doesn't block the next answer and is retried, and a deleted reply halts once and isn't edited again. The reply_not_posted log no longer has its own test.
send_thread_update swallows halts, so refresh_agent_run isn't retried and the reply only posts if Seer sends another completion hook.

Refs CW-2180
Master replaced SlackApiError with TypedSlackApiError in this test file
under strict mypy, so the merged test lost its SlackApiError import.
@sentry-junior
sentry-junior Bot force-pushed the joey--slack-agent-reply-edit-errors branch from 0baa0d9 to 88ff054 Compare November 3, 2026 16:49

@alexsohn1126 alexsohn1126 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good, thanks!

@joseph-sentry
joseph-sentry merged commit 60070e8 into master Nov 5, 2026
69 checks passed
@joseph-sentry
joseph-sentry deleted the joey--slack-agent-reply-edit-errors branch November 5, 2026 21:53
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