fix(tasks): stop stamping hedgehog reaction on interim slack relays#59858
Merged
richardsolomou merged 2 commits intoMay 28, 2026
Merged
Conversation
The reaction lifecycle on a Slack-launched task's mention message is: seedling (received) → eyes (working) → hedgehog (done) / x (failed). Only post_slack_update is supposed to flip to hedgehog, gated on COMPLETED / CANCELLED / PR-opened. RelaySlackMessageInput.reaction_emoji defaulted to "hedgehog", and the relay_message API endpoint never passes one. Because that endpoint only fires for non-terminal runs (by design — interim agent output), every mid-task relay was clearing seedling/eyes and stamping hedgehog, falsely signalling completion while the agent was still working. Make reaction_emoji optional (None) and only call update_reaction when a caller explicitly sets it. forward_pending_message still passes "x" for the delivery-failure case; the relay_message endpoint stops touching reactions and lets post_slack_update remain the sole authority on terminal-state reactions. Generated-By: PostHog Code Task-Id: 8ff1e5da-c326-4cc3-b4bf-514021d34a87
Contributor
|
Collapse the two relay reaction-behavior tests into a single parameterized test covering both the no-reaction-emoji and explicit reaction_emoji cases. Matches the repo convention of preferring parameterized tests for variations of the same logic. Generated-By: PostHog Code Task-Id: 8ff1e5da-c326-4cc3-b4bf-514021d34a87
Contributor
ClickHouse migration SQL per cloud environmentNo ClickHouse migrations changed in this PR. |
VojtechBartos
approved these changes
May 28, 2026
richardsolomou
added a commit
that referenced
this pull request
May 28, 2026
The slack relay path was fixed in #59858 to stop stamping `:hedgehog:` on interim agent replies, but `post_slack_update` still swapped the reaction to `:hedgehog:` the first time it saw a `pr_url` while the run was non-terminal. That fires when the agent is still alive (e.g. handling follow-ups), making the hog land before the task is actually done. Only terminal statuses (or post-cleanup branches) should set the hedgehog now. Generated-By: PostHog Code Task-Id: 1fd5c724-c4da-426c-b742-03aeb7eef615
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a Slack-launched task runs, the bot manages a reaction on the user's mention message as a status indicator:
:seedling::eyes::hedgehog::x:post_slack_updateis the intended single source of truth for terminal reactions — it only stamps:hedgehog:when the run reachesCOMPLETED,CANCELLED, or a PR is opened.However, every interim agent message posted back into the Slack thread via the
relay_messageendpoint was also flipping the reaction to:hedgehog:. The endpoint by design only fires for non-terminal runs (it short-circuits ontask_run.is_terminal), so users were seeing the "done" hedgehog appear repeatedly while the agent was still working.Root cause:
RelaySlackMessageInput.reaction_emojidefaulted to"hedgehog", and therelay_messageendpoint never passed an explicit value, so the default fired on every interim relay.Changes
RelaySlackMessageInput.reaction_emojiandexecute_posthog_code_agent_relay_workflow'sreaction_emojiarg now default toNone.relay_slack_messageonly callshandler.update_reaction(...)when the caller explicitly passes a reaction.forward_pending_message(the delivery-failure case that legitimately needs to mark:x:) is unchanged — it already passedreaction_emoji=\"x\"explicitly.post_slack_updateremains the sole authority on lifecycle reactions.How did you test this code?
test_relay_posts_message_and_marks_senttest to assert that an interim relay does not callupdate_reaction.test_relay_with_explicit_reaction_updates_reactionto confirm an explicitreaction_emoji=\"x\"(theforward_pending_messagepath) still flows through.Publish to changelog?
no
Docs update
No docs changes needed.
🤖 Agent context
Authored by Claude Code (Opus 4.7) via the PostHog Code sandbox. The user reported that the hedgehog emoji was appearing on their Slack mention before the task was actually done. Traced the reaction lifecycle through
products/slack_app/backend/slack_thread.py:update_reaction,products/tasks/backend/temporal/process_task/activities/post_slack_update.py(intended terminal-state authority), andproducts/tasks/backend/temporal/slack_relay/activities.py(the bug site).Considered two fixes:
\"eyes\"so interim messages reaffirm the working indicator.reaction_emojioptional (None) and only update the reaction when explicitly set.Picked (2): the existing
forward_pending_messagecaller already passes\"x\"explicitly, so the parameter is preserved for legitimate state-bearing relays; absence of an arg now means "don't touch it" rather than the previous footgun of "mark as done". This also avoids redundant Slack API calls (theupdate_reactionflow does areactions_removeper stale emoji plus areactions_add) on every interim message.