: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 as slack-app-mention-processing (#118369)
Vojta Bartoš51affd7ff8a2
diff --git a/docs/internal/slack-local-setup-guide.md b/docs/internal/slack-local-setup-guide.mdindex 534573c5f686..ac9d5cc9cc6b 100644--- a/docs/internal/slack-local-setup-guide.md+++ b/docs/internal/slack-local-setup-guide.md@@ -306,7 +306,7 @@ Tokens from the development app cannot be transferred to the production app.you and shows the response. A `202` here means the event arrived and the problem is downstream;this is how we confirmed delivery during setup.- **Temporal Web** (`http://localhost:8233`, filter workflow type- `posthog-code-slack-mention-processing`) — shows which activity the run reached. The happy path+ `slack-app-mention-processing`) — shows which activity the run reached. The happy pathends at `create_posthog_code_task_for_repo_activity`.- Going deeper, the `django` / `temporal-django-worker` logs carry `posthog_code_*` structloglines, and Slack's app **Event Deliveries** page shows delivery failures — neither was needed indiff --git a/products/slack_app/backend/api.py b/products/slack_app/backend/api.pyindex a28765e7c6c0..db7ff47ad694 100644--- a/products/slack_app/backend/api.py+++ b/products/slack_app/backend/api.py@@ -138,10 +138,7 @@ from products.slack_app.backend.temporal import (SlackAppMentionWorkflowInputs,derive_mention_workflow_id,)-from products.slack_app.backend.temporal.posthog_code_slack_mention import (- LegacyPostHogCodeSlackMentionWorkflow,- SlackAppMentionProcessingWorkflow,-)+from products.slack_app.backend.temporal.posthog_code_slack_mention import SlackAppMentionProcessingWorkflowfrom products.slack_app.backend.temporal.posthog_code_slack_mention_command import (PostHogCodeSlackMentionCommandWorkflow,)@@ -4360,7 +4357,7 @@ def _start_mention_workflow(# Use derive_mention_workflow_id as the single source of truth: the workflow persists the same# value as slack_mention_workflow_id, so dispatch and the debug-tool Temporal link stay consistent_start_posthog_code_workflow(- LegacyPostHogCodeSlackMentionWorkflow,+ SlackAppMentionProcessingWorkflow,workflow_inputs,id_prefix="posthog-code-mention",slack_team_id=slack_team_id,diff --git a/products/slack_app/backend/temporal/README.md b/products/slack_app/backend/temporal/README.mdindex 46f13835acdb..e71ea355a4cd 100644--- a/products/slack_app/backend/temporal/README.md+++ b/products/slack_app/backend/temporal/README.md@@ -12,5 +12,5 @@ For general Temporal conventions, read [`posthog/temporal/AGENTS.md`](../../../.Quick sanity checks that `discover_posthog_code_repository_via_agent_activity` is working after a deploy:-- **Temporal UI.** Filter `posthog-code-slack-mention-processing` runs. Healthy: `discover_posthog_code_repository_via_agent_activity` followed by `create_posthog_code_task_for_repo_activity`. Picker-fallback (`post_posthog_code_repo_picker_activity` after the agent) is fine occasionally, alarming if dominant.+- **Temporal UI.** Filter `slack-app-mention-processing` runs. Runs that started before the rename use `posthog-code-slack-mention-processing`. Healthy: `discover_posthog_code_repository_via_agent_activity` followed by `create_posthog_code_task_for_repo_activity`. Picker-fallback (`post_posthog_code_repo_picker_activity` after the agent) is fine occasionally, alarming if dominant.- **Slack smoke test.** In a channel with the app and >1 connected repo, `@PostHog Desktop` a message that doesn't name a repo (e.g. "investigate the failing checkout test"). A 🔍 reaction within ~10–60s means the agent ran; the task starting on a real repo means it picked one. A picker on a clear request = something's off.diff --git a/products/slack_app/backend/temporal/slack_app_mention.py b/products/slack_app/backend/temporal/slack_app_mention.pyindex f7ec79ca108a..c9985544dafd 100644--- a/products/slack_app/backend/temporal/slack_app_mention.py+++ b/products/slack_app/backend/temporal/slack_app_mention.py@@ -15,7 +15,10 @@ 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.posthog_code_slack_mention import LegacyPostHogCodeSlackMentionWorkflow+from products.slack_app.backend.temporal.posthog_code_slack_mention import (+ LegacyPostHogCodeSlackMentionWorkflow,+ SlackAppMentionProcessingWorkflow,+)from products.slack_app.backend.temporal.types import (PostHogCodeSlackMentionWorkflowInputs,SlackAppMentionWorkflowInputs,@@ -23,6 +26,8 @@ from products.slack_app.backend.temporal.types import ()SLACK_APP_MENTION_IDLE_TIMEOUT_SECONDS = 30+# Temporal patch ID: runs that started a child before this patch replay the old child type name.+_PATCH_ID_MENTION_PROCESSING_RENAME = "slack-app-mention-processing-rename-2026-10"# 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.@@ -176,6 +181,11 @@ class SlackAppMentionWorkflow(PostHogWorkflow):ALLOW_DUPLICATE mirrors the standalone dispatch's reuse policy forretries that outlive this instance's dedup keys."""+ child_type: type[SlackAppMentionProcessingWorkflow] = (+ SlackAppMentionProcessingWorkflow+ if workflow.patched(_PATCH_ID_MENTION_PROCESSING_RENAME)+ else LegacyPostHogCodeSlackMentionWorkflow+ )try:# The default parent close policy (terminate) is deliberate: an# operator killing this queue means "stop this conversation", so@@ -183,7 +193,7 @@ class SlackAppMentionWorkflow(PostHogWorkflow):# return, continue_as_new) never have a child in flight — the# serial await completes it first.await workflow.execute_child_workflow(- LegacyPostHogCodeSlackMentionWorkflow.run,+ child_type.run,message,id=derive_mention_workflow_id(message),id_reuse_policy=WorkflowIDReusePolicy.ALLOW_DUPLICATE,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 9f8a049c0132..58daf65808dc 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@@ -7,9 +7,11 @@ from typing import Any, Literalimport pytestfrom temporalio import activity+from temporalio.api.enums.v1 import EventType+from temporalio.client import WorkflowHistoryfrom temporalio.common import WorkflowIDConflictPolicy, WorkflowIDReusePolicyfrom temporalio.testing import WorkflowEnvironment-from temporalio.worker import UnsandboxedWorkflowRunner, Worker+from temporalio.worker import Replayer, UnsandboxedWorkflowRunner, Workerfrom products.slack_app.backend.services.slack_messages import SlackThreadMessagefrom products.slack_app.backend.temporal import derive_mention_workflow_id, slack_app_mention@@ -505,6 +507,42 @@ async def test_untagged_followup_forwards_without_task_creation_or_reactions():assert rec.processing_marked == []+def _child_workflow_types(history: WorkflowHistory) -> list[str]:+ return [+ event.start_child_workflow_execution_initiated_event_attributes.workflow_type.name+ for event in history.events+ if event.event_type == EventType.EVENT_TYPE_START_CHILD_WORKFLOW_EXECUTION_INITIATED+ ]+++async def test_child_type_rename_replays_runs_started_before_the_patch(monkeypatch):+ original_patched = slack_app_mention.workflow.patched++ def legacy_patched(patch_id: str) -> bool:+ if patch_id == slack_app_mention._PATCH_ID_MENTION_PROCESSING_RENAME:+ return False+ return original_patched(patch_id)++ rec = _Recorder()+ async with _Harness(rec) as h:+ monkeypatch.setattr(slack_app_mention.workflow, "patched", legacy_patched)+ legacy_handle = await _signal_with_start(h.env, h.task_queue, f"wf-{uuid.uuid4()}", _message("1.1"))+ await asyncio.wait_for(legacy_handle.result(), timeout=30)+ legacy_history = await legacy_handle.fetch_history()++ monkeypatch.setattr(slack_app_mention.workflow, "patched", original_patched)+ new_handle = await _signal_with_start(h.env, h.task_queue, f"wf-{uuid.uuid4()}", _message("1.2"))+ await asyncio.wait_for(new_handle.result(), timeout=30)+ new_history = await new_handle.fetch_history()++ assert _child_workflow_types(legacy_history) == ["posthog-code-slack-mention-processing"]+ assert _child_workflow_types(new_history) == ["slack-app-mention-processing"]+ replayer = Replayer(workflows=[SlackAppMentionWorkflow], workflow_runner=UnsandboxedWorkflowRunner())+ await replayer.replay_workflow(legacy_history)+ await replayer.replay_workflow(new_history)++@pytest.mark.asyncioasync def test_idle_exit_then_signal_with_start_processes_in_fresh_run():rec = _Recorder()