:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(slack-app): remove unprompted-answers and interview flags and two patches (#123919)
Vojta Bartošb28e476b3b74
diff --git a/products/slack_app/backend/api.py b/products/slack_app/backend/api.pyindex 7f14ea79e7bf..db10839e2a44 100644--- a/products/slack_app/backend/api.py+++ b/products/slack_app/backend/api.py@@ -50,7 +50,6 @@ from products.slack_app.backend.feature_flags import (ASSISTANT_REQUIRED_SCOPES,is_slack_app_assistant_enabled,is_slack_app_oauth_enabled,- is_slack_app_unprompted_answers_enabled,)from products.slack_app.backend.helpers import local_dev_slack_emailfrom products.slack_app.backend.logic import interview_recruitment, reply_suggestions@@ -2579,15 +2578,6 @@ def _route_untagged_question(if _us_should_handle_instead(slack_team_id, [SLACK_INTEGRATION_KIND], can_defer, incoming_host):return _proxy_event_and_return_route(request, other_domain, {ALREADY_EMITTED_HEADER: "1"})- # Most top-level posts are chatter, so the flag drops them before the author's mode read and- # user resolution. The flag is rolled out per organization, and a workspace can connect- # projects from several organizations, so each project keeps its own answer.- enabled_integration_ids = {- candidate.id for candidate in workspace_result.candidates if is_slack_app_unprompted_answers_enabled(candidate)- }- if not enabled_integration_ids:- return ROUTE_HANDLED_LOCALLY-# One indexed read, ahead of user resolution, which can call Slack's users.info for every author.if resolve_untagged_question_mode(slack_team_id, slack_user_id) == UntaggedFollowupMode.NEVER:return ROUTE_HANDLED_LOCALLY@@ -2606,8 +2596,6 @@ def _route_untagged_question(target = resolution.integration or (candidates[0] if len(candidates) == 1 else None)if target is None or SlackIntegration(target).missing_scopes(REQUIRED_SLACK_SCOPES):return ROUTE_HANDLED_LOCALLY- if target.id not in enabled_integration_ids:- return ROUTE_HANDLED_LOCALLY# A post that tags the app also arrives as an ``app_mention``, and the mention pipeline answers that copy.if _message_tags_bot(event, target):return ROUTE_HANDLED_LOCALLY@@ -4111,7 +4099,6 @@ def _handle_untagged_question_run(payload: dict) -> HttpResponse:not isinstance(event, dict)or slack.missing_scopes(REQUIRED_SLACK_SCOPES)or resolve_untagged_question_mode(integration.integration_id, slack_user_id) == UntaggedFollowupMode.NEVER- or not is_slack_app_unprompted_answers_enabled(integration)or (posthog_user := _is_org_member(integration, slack_user_id)) is Noneor not _can_access_team(posthog_user, integration)):diff --git a/products/slack_app/backend/feature_flags.py b/products/slack_app/backend/feature_flags.pyindex 4665e14b2c78..8725b6e15c9f 100644--- a/products/slack_app/backend/feature_flags.py+++ b/products/slack_app/backend/feature_flags.py@@ -48,8 +48,6 @@ logger = structlog.get_logger(__name__)SLACK_APP_AGENT_DESIGN_FLAG = "slack-app-agent-design"SLACK_APP_FORKING_FLAG = "slack-app-forking"SLACK_APP_BYOS_FLAG = "slack-app-byos"-SLACK_APP_UNPROMPTED_ANSWERS_FLAG = "slack-app-unprompted-answers"-SLACK_APP_INTERVIEW_RECRUITMENT_FLAG = "slack-app-interview-recruitment"# Linking a Slack identity to a PostHog user resolves the Slack profile and its email.@@ -149,33 +147,6 @@ def is_slack_app_byos_enabled(integration: Integration, distinct_id: str | None,)-def is_slack_app_unprompted_answers_enabled(integration: Integration) -> bool:- """Gate for answering top-level channel messages nobody tagged the app in.-- Keyed on the workspace, not the author, because the webhook checks it before it resolves- who wrote the message. Roll it out with an organization condition.- """- return _workspace_flag_enabled(- SLACK_APP_UNPROMPTED_ANSWERS_FLAG,- integration,- failure_log_key="slack_app_unprompted_answers_feature_flag_check_failed",- )---def is_slack_app_interview_recruitment_enabled(integration: Integration, distinct_id: str) -> bool:- """Gate for the interview invitations on the Home tab and after a frustration signal.-- ``distinct_id`` is the reader's PostHog distinct id, or their Slack-derived id when no- PostHog user is linked. A rule on email or a cohort only matches a linked reader.- """- return _workspace_flag_enabled(- SLACK_APP_INTERVIEW_RECRUITMENT_FLAG,- integration,- failure_log_key="slack_app_interview_recruitment_feature_flag_check_failed",- distinct_id=distinct_id,- )--def is_slack_app_assistant_enabled(integration: Integration) -> bool:"""Gate for the DM assistant: the install must hold the scopes the DM surfacecalls — ``im:history`` in particular, without which the assistant would answerdiff --git a/products/slack_app/backend/logic/feature_tips/catalog.py b/products/slack_app/backend/logic/feature_tips/catalog.pyindex d847e971fc12..87fd9b6a836a 100644--- a/products/slack_app/backend/logic/feature_tips/catalog.py+++ b/products/slack_app/backend/logic/feature_tips/catalog.py@@ -22,11 +22,7 @@ from posthog.models.user_integration import UserIntegrationfrom posthog.slack.formatting import channel_id_from_targetfrom products.mcp_store.backend.facade.api import get_active_installations-from products.slack_app.backend.feature_flags import (- is_slack_app_assistant_enabled,- is_slack_app_forking_enabled,- is_slack_app_unprompted_answers_enabled,-)+from products.slack_app.backend.feature_flags import is_slack_app_assistant_enabled, is_slack_app_forking_enabledfrom products.slack_app.backend.inbox_channel import (_get_team_channel,channel_name_from_target,@@ -472,7 +468,7 @@ class UnpromptedAnswersTip(TipFeature):)def is_eligible(self, ctx: TipContext) -> bool:- return not ctx.in_direct_message and is_slack_app_unprompted_answers_enabled(ctx.integration)+ return not ctx.in_direct_messagedef was_used(self, ctx: TipContext) -> bool:return ctx.settings.untagged_question_mode is not Nonediff --git a/products/slack_app/backend/logic/interview_recruitment.py b/products/slack_app/backend/logic/interview_recruitment.pyindex 4f1192cdaf29..ea6d82e06a43 100644--- a/products/slack_app/backend/logic/interview_recruitment.py+++ b/products/slack_app/backend/logic/interview_recruitment.py@@ -6,9 +6,8 @@ how the click is counted.Three surfaces show an invitation:- The bad-rating modal always shows the link, because the reader already chose to tell us what went wrong.-- The Home tab shows a button when the ``slack-app-interview-recruitment`` flag selects the reader.-- A private message under the answer offers the interview when the flag selects the reader and the- reader shows frustration: a thumbs-down reaction on an answer, or a message that the decision model+- The Home tab always shows a button.+- A private message under the answer offers the interview when the reader shows frustration: a thumbs-down reaction on an answer, or a message that the decision modelreads as unhappy with the assistant or PostHog. A reader gets at most one such message in ``INVITE_INTERVAL``, and"Don't ask again" stops these messages only. The model runs only after every cheap gate passes, somost answers cost no call.@@ -32,8 +31,7 @@ from posthog.llm.system_one import ChoiceAnswer, ChoiceQuestionfrom posthog.llm.system_one_client import build_system_one_clientfrom posthog.models.integration import Integration, SlackIntegration-from products.slack_app.backend.analytics import capture_slack_event, slack_distinct_id-from products.slack_app.backend.feature_flags import is_slack_app_interview_recruitment_enabled+from products.slack_app.backend.analytics import capture_slack_eventfrom products.slack_app.backend.logic.feature_tips.state import FeatureTipsState, get_state, update_statefrom products.slack_app.backend.models import SlackThreadTaskMappingfrom products.slack_app.backend.services.inbox_interactivity import post_response_url@@ -111,7 +109,7 @@ class SentimentVerdict:def linked_posthog_user(integration: Integration, slack_user_id: str) -> User | None:- """The PostHog user behind this Slack identity. Best-effort, because the result only targets the flag and labels events."""+ """The PostHog user behind this Slack identity. Best-effort, because the result only labels events and model calls."""try:return find_linked_posthog_user(slack_user_id=slack_user_id,@@ -123,15 +121,6 @@ def linked_posthog_user(integration: Integration, slack_user_id: str) -> User |return None-def is_recruiting(integration: Integration, slack_user_id: str, posthog_user: User | None) -> bool:- distinct_id = (- posthog_user.distinct_id- if posthog_user is not None and posthog_user.distinct_id- else slack_distinct_id(integration, slack_user_id)- )- return is_slack_app_interview_recruitment_enabled(integration, distinct_id)--def book_button(integration_id: int, surface: InterviewSurface, **extra: str | None) -> dict[str, Any]:# The integration id lets the cross-region interactivity router find the region that owns the click.value = {"integration_id": integration_id, "surface": surface, **{key: item for key, item in extra.items() if item}}@@ -176,8 +165,6 @@ def offer_frustration_invite(request: FrustrationInviteRequest) -> bool:# A reaction arrives after the answer, so a tip may already sit under that answer. No answer gets two prompts.if state.last_shown_at is not None and now - state.last_shown_at < TIP_GAP:return False- if not is_recruiting(integration, request.slack_user_id, request.posthog_user):- return False# The limit stops the count at the threshold, so a reader with a long history costs no full scan.thread_count = (SlackThreadTaskMapping.objects.filter(diff --git a/products/slack_app/backend/services/slack_app_home.py b/products/slack_app/backend/services/slack_app_home.pyindex 9b3ca32cb745..ef76efaf683d 100644--- a/products/slack_app/backend/services/slack_app_home.py+++ b/products/slack_app/backend/services/slack_app_home.py@@ -33,19 +33,10 @@ from posthog.models.user_integration import UserIntegrationfrom posthog.user_permissions import UserPermissionsfrom products.slack_app.backend.analytics import capture_slack_event-from products.slack_app.backend.feature_flags import (- is_slack_app_byos_enabled,- is_slack_app_oauth_enabled,- is_slack_app_unprompted_answers_enabled,-)+from products.slack_app.backend.feature_flags import is_slack_app_byos_enabled, is_slack_app_oauth_enabledfrom products.slack_app.backend.logic.feature_tips.features import SlackFeaturefrom products.slack_app.backend.logic.feature_tips.state import record_feature_used-from products.slack_app.backend.logic.interview_recruitment import (- INVITE_MESSAGE,- book_button,- invite_section,- is_recruiting,-)+from products.slack_app.backend.logic.interview_recruitment import INVITE_MESSAGE, book_button, invite_sectionfrom products.slack_app.backend.models import (ChannelWelcomeMode,SlackSettings,@@ -550,8 +541,7 @@ def render_home_view(blocks.append({"type": "divider"})blocks.extend(_linked_accounts_section_blocks(account_state, github_state))- # Section 6a — interview invitation. `interview_invite` is the section block, present only- # for a viewer the recruitment flag selects.+ # Section 6a — interview invitation. `interview_invite` is the section block.if interview_invite is not None:blocks.append({"type": "divider"})blocks.append(_section_title("💬 Talk to the team"))@@ -1841,7 +1831,7 @@ def handle_ai_preferences_block_action(payload: dict, action: dict) -> HttpResporeturn HttpResponse(status=200)if action_id == ACTION_SET_UNTAGGED_QUESTION_MODE:- if (mode := _picked_untagged_mode(action)) is not None and is_slack_app_unprompted_answers_enabled(integration):+ if (mode := _picked_untagged_mode(action)) is not None:set_untagged_question_mode(integration.integration_id, slack_user_id, mode)republish()return HttpResponse(status=200)@@ -2300,11 +2290,7 @@ def _build_home_view(tasks_state=tasks_state,stats_state=stats_state,untagged_followup_mode=resolve_untagged_followup_mode(integration, slack_user_id),- untagged_question_mode=(- resolve_untagged_question_mode(integration.integration_id, slack_user_id)- if is_slack_app_unprompted_answers_enabled(integration)- else None- ),+ untagged_question_mode=resolve_untagged_question_mode(integration.integration_id, slack_user_id),channel_welcome_mode=resolve_channel_welcome_mode(integration.integration_id) if is_admin else None,auto_model_choice=(resolve_auto_model_choice(integration.integration_id, slack_user_id) if home_user is not None else None@@ -2314,7 +2300,7 @@ def _build_home_view(has_project_access=bool(accessible),# The same settings page the GitHub card deep-links to.account_settings_url=github_state.settings_url,- interview_invite=_resolve_interview_invite(integration, slack_user_id, home_user),+ interview_invite=invite_section(INVITE_MESSAGE, book_button(integration.id, "home")),)return _HomeRender(view=view,@@ -2324,17 +2310,6 @@ def _build_home_view()-def _resolve_interview_invite(integration: Integration, slack_user_id: str, home_user: User | None) -> dict | None:- """The invitation section for a viewer the recruitment flag selects. Best-effort, like every card."""- try:- if not is_recruiting(integration, slack_user_id, home_user):- return None- except Exception:- logger.warning("slack_app_home_interview_invite_failed", exc_info=True)- return None- return invite_section(INVITE_MESSAGE, book_button(integration.id, "home"))--def _republish_home(integration: Integration,slack_user_id: str,diff --git a/products/slack_app/backend/tests/logic/test_feature_tips.py b/products/slack_app/backend/tests/logic/test_feature_tips.pyindex 403c9cfb5bad..88d6254b82b5 100644--- a/products/slack_app/backend/tests/logic/test_feature_tips.py+++ b/products/slack_app/backend/tests/logic/test_feature_tips.py@@ -39,7 +39,6 @@ class TestOfferFeatureTip:with (patch.object(offer, "post_slack_ephemeral") as self.post,patch.object(offer, "SlackIntegration"),- patch.object(catalog, "is_slack_app_unprompted_answers_enabled", return_value=False),# The decision model is not reachable here, so every pick falls back to the ranked order.patch.object(picker, "build_system_one_client", side_effect=RuntimeError("no gateway")),):diff --git a/products/slack_app/backend/tests/logic/test_interview_recruitment.py b/products/slack_app/backend/tests/logic/test_interview_recruitment.pyindex 7b997b9f0f85..3425ce6934bf 100644--- a/products/slack_app/backend/tests/logic/test_interview_recruitment.py+++ b/products/slack_app/backend/tests/logic/test_interview_recruitment.py@@ -49,7 +49,6 @@ class TestFrustrationInvite:team=self.team, kind="slack", integration_id=WORKSPACE, sensitive_config={"access_token": "xoxb-test"})with (- patch.object(interview_recruitment, "is_slack_app_interview_recruitment_enabled", return_value=True),patch.object(interview_recruitment, "post_slack_ephemeral") as self.post,patch.object(interview_recruitment, "SlackIntegration"),patch.object(interview_recruitment, "capture_slack_event") as self.capture,diff --git a/products/slack_app/backend/tests/test_thread_message_routing.py b/products/slack_app/backend/tests/test_thread_message_routing.pyindex b9bd29af3667..904b277b7302 100644--- a/products/slack_app/backend/tests/test_thread_message_routing.py+++ b/products/slack_app/backend/tests/test_thread_message_routing.py@@ -160,12 +160,11 @@ class TestRouteThreadMessage(TestCase):@parameterized.expand([- ("an untagged question", {}, True, None, False, True),- ("a private channel", {"channel_type": "group"}, True, None, False, True),+ ("an untagged question", {}, None, False, True),+ ("a private channel", {"channel_type": "group"}, None, False, True),("a request without a question word",{"text": "need signups by country from PostHog for last month"},- True,None,False,True,@@ -173,29 +172,20 @@ class TestRouteThreadMessage(TestCase):("a question that does not name PostHog",{"text": "How many people signed up last week?"},- True,None,False,True,),- ("a question to a person", {"text": "<@U_ALICE> how many signups last week?"}, True, None, False, True),- (- "a question that tags the app",- {"text": "<@U0BOT> how many signups last week?"},- True,- None,- False,- False,- ),- ("a group DM", {"channel_type": "mpim"}, True, None, False, False),- ("the flag is off", {}, False, None, False, False),- ("the author picks up only tagged messages", {}, True, UntaggedFollowupMode.NEVER, False, False),- ("an author without a PostHog account", {"user": "U_UNKNOWN"}, True, None, False, False),- ("an externally shared channel", {}, True, None, True, False),+ ("a question to a person", {"text": "<@U_ALICE> how many signups last week?"}, None, False, True),+ ("a question that tags the app", {"text": "<@U0BOT> how many signups last week?"}, None, False, False),+ ("a group DM", {"channel_type": "mpim"}, None, False, False),+ ("the author picks up only tagged messages", {}, UntaggedFollowupMode.NEVER, False, False),+ ("an author without a PostHog account", {"user": "U_UNKNOWN"}, None, False, False),+ ("an externally shared channel", {}, None, True, False),])def test_top_level_question_starts_the_untagged_question_workflow(- self, _name, overrides, flag_on, author_mode, ext_shared, expect_dispatch+ self, _name, overrides, author_mode, ext_shared, expect_dispatch):if author_mode is not None:SlackSettings.objects.create(@@ -203,7 +193,6 @@ class TestRouteThreadMessage(TestCase):)event = self._make_question_event(**overrides)with (- patch("products.slack_app.backend.api.is_slack_app_unprompted_answers_enabled", return_value=flag_on),patch("products.slack_app.backend.api.get_cached_bot_user_id", return_value="U0BOT"),patch("products.slack_app.backend.api._start_mention_workflow") as mock_start,patch("products.slack_app.backend.api._post_user_resolution_failure_reply") as mock_failure_reply,diff --git a/products/slack_app/backend/tests/test_untagged_followup_interactivity.py b/products/slack_app/backend/tests/test_untagged_followup_interactivity.pyindex c687e268ee95..0a8923a53fa0 100644--- a/products/slack_app/backend/tests/test_untagged_followup_interactivity.py+++ b/products/slack_app/backend/tests/test_untagged_followup_interactivity.py@@ -414,7 +414,6 @@ class TestUntaggedQuestionInteractivity(TestCase):action_id: str,slack_user_id: str = "U_BOB",*,- flag_on: bool = True,start_fails: bool = False,ext_shared: bool | None = False,) -> Any:@@ -442,7 +441,6 @@ class TestUntaggedQuestionInteractivity(TestCase):"products.slack_app.backend.api._start_mention_workflow",side_effect=RuntimeError("temporal down") if start_fails else None,) as mock_start,- patch("products.slack_app.backend.api.is_slack_app_unprompted_answers_enabled", return_value=flag_on),patch("products.slack_app.backend.api.channel_ext_shared_state", return_value=ext_shared),):self.client.post(@@ -517,8 +515,3 @@ class TestUntaggedQuestionInteractivity(TestCase):)assert not self._click(UNTAGGED_QUESTION_ACTION_RUN).called-- def test_confirmation_after_the_flag_was_turned_off_answers_nothing(self, mock_slack_cls, mock_post):- mock_slack_cls.slack_config.return_value = {"SLACK_APP_SIGNING_SECRET": self.signing_secret}-- assert not self._click(UNTAGGED_QUESTION_ACTION_RUN, flag_on=False).calleddiff --git a/products/tasks/backend/temporal/process_task/slack_agent_design_relay.py b/products/tasks/backend/temporal/process_task/slack_agent_design_relay.pyindex 320da580063e..13ed85515c09 100644--- a/products/tasks/backend/temporal/process_task/slack_agent_design_relay.py+++ b/products/tasks/backend/temporal/process_task/slack_agent_design_relay.py@@ -59,7 +59,6 @@ _ACTIVITY_TIMEOUT = timedelta(seconds=30)_ACTIVITY_RETRY = RetryPolicy(maximum_attempts=3)# The parent's progress step that the first setup line shows._SANDBOX_SETUP_STEP = "sandbox"-_PATCH_ID_STREAM_ENDED = "tasks-slack-relay-stream-ended"def _trace_key(trace_id: Optional[str]) -> Optional[str]:@@ -362,10 +361,8 @@ class SlackAgentDesignRelayWorkflow(PostHogWorkflow):start_to_close_timeout=_ACTIVITY_TIMEOUT,retry_policy=_ACTIVITY_RETRY,)- # An older activity returns None, which means the stream is still open. Histories that- # carry the patch marker replay with deprecate_patch; delete it once those runs drain.+ # An older activity returns None, which means the stream is still open.if stream_open is False:- workflow.deprecate_patch(_PATCH_ID_STREAM_ENDED)self._stream_ended = True@workflow.rundiff --git a/products/tasks/backend/temporal/process_task/tests/test_workflow.py b/products/tasks/backend/temporal/process_task/tests/test_workflow.pyindex ec77b677f699..da01958c6d13 100644--- a/products/tasks/backend/temporal/process_task/tests/test_workflow.py+++ b/products/tasks/backend/temporal/process_task/tests/test_workflow.py@@ -2531,7 +2531,6 @@ class TestProcessTaskWorkflowUnit:start_slack_relay_mock = AsyncMock()monkeypatch.setattr(workflow, "_start_slack_agent_design_relay", start_slack_relay_mock)monkeypatch.setattr(process_task_workflow_module.workflow, "patched", Mock(return_value=True))- monkeypatch.setattr(process_task_workflow_module.workflow, "deprecate_patch", Mock())monkeypatch.setattr(process_task_workflow_module.workflow, "now", Mock(return_value=datetime.now(UTC)))result = await workflow.run(diff --git a/products/tasks/backend/temporal/process_task/workflow.py b/products/tasks/backend/temporal/process_task/workflow.pyindex d693546da17f..064af72e4ee4 100644--- a/products/tasks/backend/temporal/process_task/workflow.py+++ b/products/tasks/backend/temporal/process_task/workflow.py@@ -346,12 +346,6 @@ SELF_DRIVING_QUOTA_RECHECK_INTERVAL = timedelta(minutes=5)_ORIGIN_PRODUCT_SIGNAL_REPORT = "signal_report"-# Gates the forward of the agent_final_text signal to the Slack relay. A worker without the-# handler records that signal in history and sends nothing, so a replay that forwards it emits a-# command the history does not have (TMPRL1100). Every worker now has the handler, so the patch is-# deprecated; delete it once histories that carry the marker drain.-_PATCH_ID_SLACK_AGENT_FINAL_TEXT = "tasks-slack-agent-final-text"-# Progress steps of sandbox setup. The Slack plan shows them until the first turn starts._SLACK_SETUP_PROGRESS_STEPS = frozenset({"sandbox", "clone", "checkout", "wizard", "agent"})@@ -446,8 +440,6 @@ class ProcessTaskWorkflow(PostHogWorkflow):self._sandbox_ttl_snapshot_taken: bool = False# Decided once at workflow start; gates the placeholder skip + relay spawn.self._is_agent_design_enabled: bool = False- # See _PATCH_ID_SLACK_AGENT_FINAL_TEXT.- self._forwards_agent_final_text: bool = Falseself._dev_stack_preview_enabled: bool = False# Deadline-based so heartbeats waking the event loop don't keep resetting the timer.self._self_driving_quota_next_check_at: Optional[datetime] = None@@ -1197,9 +1189,6 @@ class ProcessTaskWorkflow(PostHogWorkflow):)self._sandbox_url = sandbox_urlself._sandbox_connect_token = sandbox_connect_token- if self._is_agent_design_enabled:- workflow.deprecate_patch(_PATCH_ID_SLACK_AGENT_FINAL_TEXT)- self._forwards_agent_final_text = Truerelay_task: asyncio.Task[None] | None = self._spawn_event_relay(sandbox_url, sandbox_connect_token, sandbox_id@@ -3488,8 +3477,6 @@ class ProcessTaskWorkflow(PostHogWorkflow):@temporalio.workflow.signalasync def agent_final_text(self, payload: dict[str, Any]) -> None:- if not self._forwards_agent_final_text:- returnawait self._forward_to_slack_relay(SlackAgentDesignRelayWorkflow.agent_final_text, payload, "slack_final_text_forward_failed")