: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
chore(slack-app): start mention processing runs under a slack-app workflow id (#118612)
Vojta Bartošbad6184a8417
diff --git a/products/slack_app/backend/api.py b/products/slack_app/backend/api.pyindex c645f39a9f1d..7136fa913254 100644--- a/products/slack_app/backend/api.py+++ b/products/slack_app/backend/api.py@@ -4359,7 +4359,7 @@ def _start_mention_workflow(_start_posthog_code_workflow(SlackAppMentionProcessingWorkflow,workflow_inputs,- id_prefix="posthog-code-mention",+ id_prefix="slack-app-mention-processing",slack_team_id=slack_team_id,event=event,event_id=event_id,diff --git a/products/slack_app/backend/temporal/activities/task_creation.py b/products/slack_app/backend/temporal/activities/task_creation.pyindex 1215c9725e8d..1cc49a92be79 100644--- a/products/slack_app/backend/temporal/activities/task_creation.py+++ b/products/slack_app/backend/temporal/activities/task_creation.py@@ -533,6 +533,9 @@ def build_thread_context_update(return ThreadContextUpdate(block=block, watermark=new_watermark, messages=in_window)+MENTION_WORKFLOW_ID_PREFIX = "slack-app-mention-processing-"++def derive_mention_workflow_id(inputs: PostHogCodeSlackMentionWorkflowInputs) -> str:"""Construct the dispatch workflow id from webhook inputs.@@ -548,7 +551,7 @@ def derive_mention_workflow_id(inputs: PostHogCodeSlackMentionWorkflowInputs) ->suffix = f"{event.get('channel', '')}:{event.get('ts', '')}"if inputs.untagged_followup_confirmed:suffix = f"{suffix}:confirmed"- return f"posthog-code-mention-{inputs.slack_team_id}:{suffix}"+ return f"{MENTION_WORKFLOW_ID_PREFIX}{inputs.slack_team_id}:{suffix}"@activity.defndiff --git a/products/slack_app/backend/temporal/slack_app_mention.py b/products/slack_app/backend/temporal/slack_app_mention.pyindex 78dbac9d84fa..f0fbaff4725d 100644--- a/products/slack_app/backend/temporal/slack_app_mention.py+++ b/products/slack_app/backend/temporal/slack_app_mention.py@@ -15,6 +15,7 @@ from products.slack_app.backend.temporal import (mark_slack_app_message_queued_activity,post_posthog_code_internal_error_activity,)+from products.slack_app.backend.temporal.activities.task_creation import MENTION_WORKFLOW_ID_PREFIXfrom products.slack_app.backend.temporal.slack_app_mention_processing import SlackAppMentionProcessingWorkflowfrom products.slack_app.backend.temporal.types import (PostHogCodeSlackMentionWorkflowInputs,@@ -25,6 +26,9 @@ from products.slack_app.backend.temporal.types import (SLACK_APP_MENTION_IDLE_TIMEOUT_SECONDS = 30# deprecate_patch keeps runs that recorded the rename marker replayable._PATCH_ID_MENTION_PROCESSING_RENAME = "slack-app-mention-processing-rename-2026-10"+# Runs that started a child before this patch replay the child under its legacy workflow ID.+_PATCH_ID_MENTION_PROCESSING_ID_RENAME = "slack-app-mention-processing-id-rename-2026-10"+_LEGACY_MENTION_WORKFLOW_ID_PREFIX = "posthog-code-mention-"# Dedup keys carried across continue_as_new. Bounded so the carry-over payload# stays small; old keys only matter for Slack retries, which arrive within# minutes of the original event.@@ -93,6 +97,10 @@ class SlackAppMentionWorkflow(PostHogWorkflow):def _seed(self, inputs: SlackAppMentionWorkflowInputs) -> None:for key in inputs.processed_event_keys:+ # Keys carried over by continue_as_new before the ID rename use the legacy prefix.+ # Map them to the current prefix so that a Slack retry of a carried message stays deduped.+ if key.startswith(_LEGACY_MENTION_WORKFLOW_ID_PREFIX):+ key = MENTION_WORKFLOW_ID_PREFIX + key.removeprefix(_LEGACY_MENTION_WORKFLOW_ID_PREFIX)self._seen_keys[key] = Nonefor message in inputs.pending_messages:self._seen_keys.setdefault(derive_mention_workflow_id(message), None)@@ -179,6 +187,9 @@ class SlackAppMentionWorkflow(PostHogWorkflow):retries that outlive this instance's dedup keys."""workflow.deprecate_patch(_PATCH_ID_MENTION_PROCESSING_RENAME)+ child_id = derive_mention_workflow_id(message)+ if not workflow.patched(_PATCH_ID_MENTION_PROCESSING_ID_RENAME):+ child_id = _LEGACY_MENTION_WORKFLOW_ID_PREFIX + child_id.removeprefix(MENTION_WORKFLOW_ID_PREFIX)try:# The default parent close policy (terminate) is deliberate: an# operator killing this queue means "stop this conversation", so@@ -188,7 +199,7 @@ class SlackAppMentionWorkflow(PostHogWorkflow):await workflow.execute_child_workflow(SlackAppMentionProcessingWorkflow.run,message,- id=derive_mention_workflow_id(message),+ id=child_id,id_reuse_policy=WorkflowIDReusePolicy.ALLOW_DUPLICATE,execution_timeout=SLACK_APP_MENTION_CHILD_EXECUTION_TIMEOUT,)diff --git a/products/slack_app/backend/temporal/tests/activities/test_task_creation.py b/products/slack_app/backend/temporal/tests/activities/test_task_creation.pyindex a7c44cbb57ee..e0c3f0a51ac7 100644--- a/products/slack_app/backend/temporal/tests/activities/test_task_creation.py+++ b/products/slack_app/backend/temporal/tests/activities/test_task_creation.py@@ -646,4 +646,4 @@ class TestDeriveMentionWorkflowId:def test_id_is_stable_without_a_slack_event_id(self):inputs = self._inputs(slack_event_id=None)- assert derive_mention_workflow_id(inputs) == "posthog-code-mention-T_SLACK:C001:1001.0000"+ assert derive_mention_workflow_id(inputs) == "slack-app-mention-processing-T_SLACK:C001:1001.0000"diff --git a/products/slack_app/backend/temporal/tests/test_slack_app_mention_workflow.py b/products/slack_app/backend/temporal/tests/test_slack_app_mention_workflow.pyindex c32a3023b178..3f08585c5daa 100644--- a/products/slack_app/backend/temporal/tests/test_slack_app_mention_workflow.py+++ b/products/slack_app/backend/temporal/tests/test_slack_app_mention_workflow.py@@ -616,7 +616,8 @@ async def test_hung_child_times_out_and_queue_continues(monkeypatch):@pytest.mark.asyncio-async def test_continue_as_new_carry_over_processes_pending_and_dedups_seen():[email protected]("carried_key_prefix", ["slack-app-mention-processing-", "posthog-code-mention-"])+async def test_continue_as_new_carry_over_processes_pending_and_dedups_seen(carried_key_prefix: str):rec = _Recorder()pending = _message("1.1", event_id="Ev-pending")already_seen = _message("1.2", event_id="Ev-seen")@@ -631,7 +632,10 @@ async def test_continue_as_new_carry_over_processes_pending_and_dedups_seen():SlackAppMentionWorkflow.run,SlackAppMentionWorkflowInputs(pending_messages=[pending],- processed_event_keys=[derive_mention_workflow_id(already_seen)],+ processed_event_keys=[+ carried_key_prefix+ + derive_mention_workflow_id(already_seen).removeprefix("slack-app-mention-processing-")+ ],),id=f"wf-{uuid.uuid4()}",task_queue=h.task_queue,diff --git a/products/slack_app/backend/tests/test_followup_forwarding.py b/products/slack_app/backend/tests/test_followup_forwarding.pyindex f2a99290df78..5525d0353e7c 100644--- a/products/slack_app/backend/tests/test_followup_forwarding.py+++ b/products/slack_app/backend/tests/test_followup_forwarding.py@@ -239,7 +239,9 @@ class TestCreatePostHogCodeTaskForRepoActivity(TestCase):# Mention-dispatch debug pointer persisted on the new run.# No explicit envelope event_id → falls back to "<channel>:<ts>".- assert task.latest_run.state["slack_mention_workflow_id"] == "posthog-code-mention-T_SLACK:C123:1234.5678"+ assert (+ task.latest_run.state["slack_mention_workflow_id"] == "slack-app-mention-processing-T_SLACK:C123:1234.5678"+ )mock_execute_workflow.assert_called_once()call_kwargs = mock_execute_workflow.call_args.kwargs@@ -545,7 +547,7 @@ class TestCreatePostHogCodeTaskForRepoActivity(TestCase):)task = self.Task.objects.get(team=self.team)- assert task.latest_run.state["slack_mention_workflow_id"] == "posthog-code-mention-T_SLACK:Ev01234567"+ assert task.latest_run.state["slack_mention_workflow_id"] == "slack-app-mention-processing-T_SLACK:Ev01234567"@patch("products.tasks.backend.facade.temporal.dispatch_task_processing_workflow")@patch("posthog.models.integration.SlackIntegration")@@ -915,7 +917,7 @@ class TestForwardPostHogCodeFollowupActivity(TestCase):assert new_run.state.get("initial_prompt_override") == "do something"# Resume path also annotates the new run with the mention-dispatch pointer.- assert new_run.state.get("slack_mention_workflow_id") == "posthog-code-mention-T_SLACK:C123:1234.5678"+ assert new_run.state.get("slack_mention_workflow_id") == "slack-app-mention-processing-T_SLACK:C123:1234.5678"mock_slack_instance.client.reactions_add.assert_called_once_with(channel="C123", timestamp="1234.5679", name="eyes"@@ -1572,14 +1574,14 @@ class TestEventLevelDedupe(SimpleTestCase):slack_team_id = "T_SLACK"event_id = "Ev123456"event_id_or_fallback = event_id- wf_id_1 = f"posthog-code-mention-{slack_team_id}:{event_id_or_fallback}"- wf_id_2 = f"posthog-code-mention-{slack_team_id}:{event_id_or_fallback}"+ wf_id_1 = f"slack-app-mention-processing-{slack_team_id}:{event_id_or_fallback}"+ wf_id_2 = f"slack-app-mention-processing-{slack_team_id}:{event_id_or_fallback}"assert wf_id_1 == wf_id_2def test_different_event_ids_produce_different_workflow_ids(self):slack_team_id = "T_SLACK"- wf_id_1 = f"posthog-code-mention-{slack_team_id}:Ev111"- wf_id_2 = f"posthog-code-mention-{slack_team_id}:Ev222"+ wf_id_1 = f"slack-app-mention-processing-{slack_team_id}:Ev111"+ wf_id_2 = f"slack-app-mention-processing-{slack_team_id}:Ev222"assert wf_id_1 != wf_id_2def test_fallback_uses_channel_and_ts(self):@@ -1588,8 +1590,8 @@ class TestEventLevelDedupe(SimpleTestCase):channel = "C123"ts = "1234.5678"event_id_or_fallback = event_id if event_id else f"{channel}:{ts}"- wf_id = f"posthog-code-mention-{slack_team_id}:{event_id_or_fallback}"- assert wf_id == "posthog-code-mention-T_SLACK:C123:1234.5678"+ wf_id = f"slack-app-mention-processing-{slack_team_id}:{event_id_or_fallback}"+ assert wf_id == "slack-app-mention-processing-T_SLACK:C123:1234.5678"class TestSafeReact(UnitTestCase):diff --git a/products/tasks/backend/presentation/serializers.py b/products/tasks/backend/presentation/serializers.pyindex b9e5bd5cb193..4e61db32ae7a 100644--- a/products/tasks/backend/presentation/serializers.py+++ b/products/tasks/backend/presentation/serializers.py@@ -5016,7 +5016,7 @@ class SlackThreadContextRunSerializer(serializers.Serializer):allow_null=True,help_text=("Temporal workflow id of the Slack mention that dispatched this run "- "(`posthog-code-mention-<workspace>:<event_id_or_channel:ts>`). Null for runs "+ "(`slack-app-mention-processing-<workspace>:<event_id_or_channel:ts>`). Null for runs ""created before this field was persisted."),)diff --git a/products/tasks/frontend/generated/api.schemas.ts b/products/tasks/frontend/generated/api.schemas.tsindex f4589fbd9667..22acc2b537c4 100644--- a/products/tasks/frontend/generated/api.schemas.ts+++ b/products/tasks/frontend/generated/api.schemas.ts@@ -5024,7 +5024,7 @@ export interface SlackThreadContextRunApi {*/task_processing_workflow_url: string | null/**- * Temporal workflow id of the Slack mention that dispatched this run (`posthog-code-mention-<workspace>:<event_id_or_channel:ts>`). Null for runs created before this field was persisted.+ * Temporal workflow id of the Slack mention that dispatched this run (`slack-app-mention-processing-<workspace>:<event_id_or_channel:ts>`). Null for runs created before this field was persisted.* @nullable*/mention_workflow_id: string | nulldiff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex e74d1f8476d7..c7a35fe912fb 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -103283,7 +103283,7 @@ export namespace Schemas {*/task_processing_workflow_url: string | null;/**- * Temporal workflow id of the Slack mention that dispatched this run (`posthog-code-mention-<workspace>:<event_id_or_channel:ts>`). Null for runs created before this field was persisted.+ * Temporal workflow id of the Slack mention that dispatched this run (`slack-app-mention-processing-<workspace>:<event_id_or_channel:ts>`). Null for runs created before this field was persisted.* @nullable*/mention_workflow_id: string | null;