Skip to content

: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.

chore(temporal): cutover posthog-code slack workflows to tasks queue (#62179)

Vojta Bartoš6b807bd39908
diff --git a/posthog/management/commands/start_temporal_worker.py b/posthog/management/commands/start_temporal_worker.py
index b7e654fe843f..29294e5bb888 100644
--- a/posthog/management/commands/start_temporal_worker.py
+++ b/posthog/management/commands/start_temporal_worker.py
@@ -580,12 +580,14 @@ class Command(BaseCommand):
tag_queries(kind="temporal")
- # Max AI traces span the Django request and the Temporal activity that runs the agent loop.
- # Without the OTel plugin on the worker, every span emitted from an activity is a root span
- # and the conversation trace splits across disconnected pieces. Force-enable for that queue
- # so investigations don't depend on an operator flipping TEMPORAL_OTEL_PLUGIN_ENABLED.
+ # Max AI and tasks-agent traces span the Django request and the Temporal activity that runs
+ # the agent loop. Without the OTel plugin on the worker, every span emitted from an activity
+ # is a root span and the conversation trace splits across disconnected pieces. Force-enable
+ # for both queues so investigations don't depend on an operator flipping
+ # TEMPORAL_OTEL_PLUGIN_ENABLED.
enable_otel = (
- settings.TEMPORAL_OTEL_PLUGIN_ENABLED is True or task_queue == settings.MAX_AI_TASK_QUEUE
+ settings.TEMPORAL_OTEL_PLUGIN_ENABLED is True
+ or task_queue in (settings.MAX_AI_TASK_QUEUE, settings.TASKS_TASK_QUEUE)
) and settings.OTEL_SERVICE_NAME is not None
if enable_otel is True:
# Mypy doesn't understand we have already checked settings.OTEL_SERVICE_NAME
diff --git a/posthog/temporal/ai/__init__.py b/posthog/temporal/ai/__init__.py
index 9475aac37188..8607aadc31b3 100644
--- a/posthog/temporal/ai/__init__.py
+++ b/posthog/temporal/ai/__init__.py
@@ -32,10 +32,10 @@ from .sync_vectors import (
get_approximate_actions_count,
)
-# The PostHog Code Slack workflows handed off to ProcessTaskWorkflow on the tasks
-# queue once a repo was picked, so the two queues were already paired. Exposing
-# them as a subset lets the tasks-agent worker register them alongside the AI
-# worker during the migration to a single queue.
+# PostHog Code Slack workflows live on TASKS_TASK_QUEUE alongside ProcessTaskWorkflow,
+# the worker they hand off to once a repo is picked. The subset is kept exported so
+# start_temporal_worker can register it on that queue without pulling in unrelated AI
+# workflows.
POSTHOG_CODE_SLACK_WORKFLOWS = [
PostHogCodeSlackMentionWorkflow,
PostHogCodeSlackMentionCommandWorkflow,
@@ -54,7 +54,6 @@ AI_WORKFLOWS = [
ResearchAgentWorkflow,
SummarizeLLMTracesWorkflow,
SlackConversationRunnerWorkflow,
- *POSTHOG_CODE_SLACK_WORKFLOWS,
AnomalyInvestigationWorkflow,
]
@@ -67,7 +66,6 @@ AI_ACTIVITIES = [
process_research_agent_activity,
summarize_llm_traces_activity,
process_slack_conversation_activity,
- *POSTHOG_CODE_SLACK_ACTIVITIES,
investigate_anomaly_activity,
]
diff --git a/posthog/temporal/ai/slack_app/__init__.py b/posthog/temporal/ai/slack_app/__init__.py
index d3518ca9ef97..ece478dae9ab 100644
--- a/posthog/temporal/ai/slack_app/__init__.py
+++ b/posthog/temporal/ai/slack_app/__init__.py
@@ -1,9 +1,8 @@
"""Temporal activities for the PostHog Slack App.
-Activities living here run on ``settings.MAX_AI_TASK_QUEUE`` and are imported
-by ``posthog/temporal/ai/posthog_code_slack_mention.py`` and
-``posthog/temporal/ai/posthog_code_slack_mention_command.py`` at module load
-time.
+Activities living here run on ``settings.TASKS_TASK_QUEUE`` and are imported by
+``posthog_code_slack_mention.py`` and ``posthog_code_slack_mention_command.py``
+in this package at module load time.
"""
from posthog.temporal.ai.slack_app.activities import (
diff --git a/posthog/temporal/tests/ai/test_module_integrity.py b/posthog/temporal/tests/ai/test_module_integrity.py
index 82595673ab86..41cedf9d4ba9 100644
--- a/posthog/temporal/tests/ai/test_module_integrity.py
+++ b/posthog/temporal/tests/ai/test_module_integrity.py
@@ -25,9 +25,6 @@ class TestAITemporalModuleIntegrity:
"ResearchAgentWorkflow",
"SummarizeLLMTracesWorkflow",
"SlackConversationRunnerWorkflow",
- "PostHogCodeSlackMentionWorkflow",
- "PostHogCodeSlackMentionCommandWorkflow",
- "PostHogCodeSlackTerminateTaskWorkflow",
"AnomalyInvestigationWorkflow",
]
actual_workflow_names = [workflow.__name__ for workflow in ai.AI_WORKFLOWS]
@@ -55,25 +52,6 @@ class TestAITemporalModuleIntegrity:
"process_research_agent_activity",
"summarize_llm_traces_activity",
"process_slack_conversation_activity",
- "enforce_posthog_code_billing_quota_activity",
- "resolve_posthog_code_slack_user_activity",
- "handle_posthog_code_rules_command_activity",
- "handle_posthog_code_slack_mention_command_activity",
- "resolve_posthog_code_slack_command_user_activity",
- "collect_posthog_code_thread_messages_activity",
- "create_posthog_code_routing_rule_activity",
- "cascade_posthog_code_repository_activity",
- "discover_posthog_code_repository_via_agent_activity",
- "classify_posthog_code_task_needs_repo_activity",
- "classify_untagged_followup_activity",
- "post_posthog_code_no_repos_activity",
- "post_posthog_code_repo_picker_activity",
- "block_posthog_code_task_if_no_personal_github_activity",
- "create_posthog_code_task_for_repo_activity",
- "forward_posthog_code_followup_activity",
- "post_posthog_code_picker_timeout_activity",
- "post_posthog_code_internal_error_activity",
- "process_posthog_code_terminate_task_activity",
"investigate_anomaly_activity",
]
actual_activity_names = [activity.__name__ for activity in ai.AI_ACTIVITIES]
diff --git a/products/slack_app/backend/api.py b/products/slack_app/backend/api.py
index b848a15dc75b..201f0ee6f118 100644
--- a/products/slack_app/backend/api.py
+++ b/products/slack_app/backend/api.py
@@ -1495,7 +1495,7 @@ def _start_posthog_code_workflow(
workflow_cls.run,
workflow_inputs,
id=workflow_id,
- task_queue=settings.MAX_AI_TASK_QUEUE,
+ task_queue=settings.TASKS_TASK_QUEUE,
id_conflict_policy=WorkflowIDConflictPolicy.USE_EXISTING,
id_reuse_policy=WorkflowIDReusePolicy.ALLOW_DUPLICATE,
)
@@ -3236,7 +3236,7 @@ def _handle_terminate_task_submit(payload: dict) -> HttpResponse:
PostHogCodeSlackTerminateTaskWorkflow.run,
PostHogCodeSlackInteractivityInputs(payload=payload),
id=workflow_id,
- task_queue=settings.MAX_AI_TASK_QUEUE,
+ task_queue=settings.TASKS_TASK_QUEUE,
id_conflict_policy=WorkflowIDConflictPolicy.USE_EXISTING,
id_reuse_policy=WorkflowIDReusePolicy.ALLOW_DUPLICATE,
)