: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): remove the slack-app-model-router flag (#117535)
Vojta Bartošf1b1fa6ba3c7
diff --git a/posthog/temporal/ai/slack_app/activities/model_router.py b/posthog/temporal/ai/slack_app/activities/model_router.pyindex bad0bccd96f7..3401b4b63405 100644--- a/posthog/temporal/ai/slack_app/activities/model_router.py+++ b/posthog/temporal/ai/slack_app/activities/model_router.py@@ -25,7 +25,6 @@ from products.slack_app.backend.facade.run_preferences import (ModelRouterOption,model_router_options,)-from products.slack_app.backend.feature_flags import is_slack_app_model_router_enabledfrom products.slack_app.backend.services.slack_settings import resolve_auto_model_choicelogger = structlog.get_logger(__name__)@@ -145,7 +144,7 @@ def classify_slack_app_model_router_activity(input: SlackAppModelRouterInput) ->integration_id=input.slack_team_id,)user = User.objects.filter(id=input.user_id).first()- if user is None or not is_slack_app_model_router_enabled(integration, distinct_id=user.distinct_id):+ if user is None:return overridetrace_id = _thread_trace_id(input.slack_team_id, input.thread_ts)diff --git a/posthog/temporal/tests/ai/slack_app/activities/test_model_router_activity.py b/posthog/temporal/tests/ai/slack_app/activities/test_model_router_activity.pyindex 919bf595b542..645cc8759432 100644--- a/posthog/temporal/tests/ai/slack_app/activities/test_model_router_activity.py+++ b/posthog/temporal/tests/ai/slack_app/activities/test_model_router_activity.py@@ -25,7 +25,6 @@ from products.tasks.backend.facade.ai_run_defaults import update_user_ai_run_preMODULE = "posthog.temporal.ai.slack_app.activities.model_router"OPTIONS_MODULE = "products.slack_app.backend.services.model_router"-FLAG = "products.slack_app.backend.feature_flags.posthoganalytics.feature_enabled"SLACK_USER_ID = "U_ROUTER"_EFFORTS = ("low", "medium", "high", "xhigh", "max")@@ -112,21 +111,19 @@ def _decision_records(capture: MagicMock) -> list[Mapping[str, Any]]:class TestRouteSlackAppModelActivity:@pytest.mark.parametrize(- "opted_in,flag_enabled,override",+ "opted_in,override",[- (True, True, SlackAppModelOverride(model="gpt-6-sol", reasoning_effort=None)),- (False, True, None),- (True, False, None),+ (True, SlackAppModelOverride(model="gpt-6-sol", reasoning_effort=None)),+ (False, None),],- ids=["model_named_in_mention", "not_opted_in", "flag_off"],+ ids=["model_named_in_mention", "not_opted_in"],)def test_ineligible_mention_keeps_its_override_without_asking_the_router(- self, integration, user, opted_in, flag_enabled, override+ self, integration, user, opted_in, override):if opted_in:_opt_in(integration)with (- patch(FLAG, return_value=flag_enabled),patch(f"{MODULE}.build_system_one_client") as build_client,patch(f"{MODULE}.capture_slack_event"),):@@ -154,7 +151,6 @@ class TestRouteSlackAppModelActivity:integration.team_id, user.id, runtime_adapter="codex", model="gpt-6-sol", reasoning_effort="high")with (- patch(FLAG, return_value=True),patch(f"{MODULE}.build_system_one_client", return_value=_client_picking(picked)),patch(f"{MODULE}.capture_slack_event"),):@@ -173,7 +169,6 @@ class TestRouteSlackAppModelActivity:else nullcontext())with (- patch(FLAG, return_value=True),patch(f"{MODULE}.build_system_one_client", return_value=client),patch(f"{MODULE}.capture_slack_event") as capture,broken_options,@@ -186,7 +181,6 @@ class TestRouteSlackAppModelActivity:def test_routed_mention_records_what_the_decision_model_read_and_picked(self, integration, user):_opt_in(integration)with (- patch(FLAG, return_value=True),patch(f"{MODULE}.build_system_one_client", return_value=_client_picking("claude-opus-5-5")),patch(f"{MODULE}.capture_slack_event") as capture,):@@ -207,7 +201,6 @@ class TestRouteSlackAppModelActivity:)client = _client_picking()with (- patch(FLAG, return_value=True),patch("products.tasks.backend.facade.run_config.get_model_access_error", return_value=None),patch(f"{OPTIONS_MODULE}.available_model_choices", return_value=CHOICES),patch(f"{OPTIONS_MODULE}.offered_model_choices", return_value=CHOICES),diff --git a/products/slack_app/backend/feature_flags.py b/products/slack_app/backend/feature_flags.pyindex 4328f76ec209..d9224b17caf7 100644--- a/products/slack_app/backend/feature_flags.py+++ b/products/slack_app/backend/feature_flags.py@@ -48,7 +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_PROJECT_PICKER_FLAG = "slack-app-project-picker"-SLACK_APP_MODEL_ROUTER_FLAG = "slack-app-model-router"SLACK_APP_INSIGHT_UNFURL_CHARTS_FLAG = "slack-app-insight-unfurl-charts"SLACK_APP_REPLY_SUGGESTIONS_FLAG = "slack-app-reply-suggestions"@@ -140,16 +139,6 @@ def is_slack_app_project_picker_enabled(integration: Integration, distinct_id: s)-def is_slack_app_model_router_enabled(integration: Integration, distinct_id: str | None = None) -> bool:- """Gate for the App Home "Use auto model choice" toggle. The router also needs the toggle on."""- return _workspace_flag_enabled(- SLACK_APP_MODEL_ROUTER_FLAG,- integration,- failure_log_key="slack_app_model_router_feature_flag_check_failed",- distinct_id=distinct_id,- )--def is_slack_app_insight_unfurl_charts_enabled(integration: Integration, distinct_id: str | None = None) -> bool:"""Gate for the chart image in an insight link unfurl. The image block refers to aPostHog-hosted url, so it needs no scope beyond the ones the text unfurl already uses.diff --git a/products/slack_app/backend/services/slack_app_home.py b/products/slack_app/backend/services/slack_app_home.pyindex 1b50f94e6d71..142b842c4864 100644--- a/products/slack_app/backend/services/slack_app_home.py+++ b/products/slack_app/backend/services/slack_app_home.py@@ -33,7 +33,7 @@ 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_model_router_enabled, is_slack_app_oauth_enabled+from products.slack_app.backend.feature_flags import is_slack_app_oauth_enabledfrom products.slack_app.backend.models import (ChannelWelcomeMode,SlackSettings,@@ -480,7 +480,7 @@ def render_home_view(blocks.append({"type": "divider"})blocks.extend(_active_model_blocks(run_defaults))blocks.extend(_personal_section_blocks(run_defaults))- # `None` means the `slack-app-model-router` flag is off for this viewer.+ # `None` means no PostHog user is linked to this viewer.if auto_model_choice is not None:blocks.extend(_auto_model_choice_blocks(auto_model_choice))@@ -1701,7 +1701,7 @@ def handle_ai_preferences_block_action(payload: dict, action: dict) -> HttpResporeturn HttpResponse(status=200)if action_id == ACTION_SET_AUTO_MODEL_CHOICE:- # A stale view must not turn the router on for someone the flag no longer covers.+ # The router runs as a PostHog user, so a viewer with no linked user cannot turn it on.if _auto_model_choice_offered(integration, slack_user_id):enabled = any(option.get("value") == AUTO_MODEL_CHOICE_VALUE for option in action.get("selected_options") or []@@ -2407,10 +2407,7 @@ def _resolve_run_defaults_state(def _auto_model_choice_offered(integration: Integration, slack_user_id: str) -> bool:- home_user = _resolve_home_user(integration, slack_user_id)- if home_user is None:- return False- return is_slack_app_model_router_enabled(integration, distinct_id=home_user.distinct_id)+ return _resolve_home_user(integration, slack_user_id) is not Nonedef _resolve_account_state(integration: Integration, slack_user_id: str) -> AccountState:diff --git a/products/slack_app/backend/tests/services/test_slack_app_home.py b/products/slack_app/backend/tests/services/test_slack_app_home.pyindex 4bfd58c1b1d0..e04736b858bc 100644--- a/products/slack_app/backend/tests/services/test_slack_app_home.py+++ b/products/slack_app/backend/tests/services/test_slack_app_home.py@@ -574,29 +574,24 @@ class TestAutoModelChoiceToggle:}@pytest.mark.parametrize(- "flag_enabled,checked,expected",+ "linked,checked,expected",[(True, True, True),(True, False, False),- # A view rendered before the flag turned off must not opt anyone in.+ # The router runs as a PostHog user, so a viewer with no linked user must not opt in.(False, True, None),],)- def test_toggle_is_stored_for_the_clicking_user_only_while_the_flag_is_on(- self, slack_integration, mock_slack_client, flag_enabled, checked, expected+ def test_toggle_is_stored_for_the_clicking_user_only_when_linked_to_a_posthog_user(+ self, slack_integration, mock_slack_client, linked, checked, expected):- User.objects.create_and_join(slack_integration.team.organization, "[email protected]", None)+ if linked:+ User.objects.create_and_join(slack_integration.team.organization, "[email protected]", None)SlackUserProfileCache.objects.create(integration=slack_integration, slack_user_id="U001", email="[email protected]")payload = self._toggle(checked)- with (- patch(- "products.slack_app.backend.feature_flags.posthoganalytics.feature_enabled",- return_value=flag_enabled,- ),- patch("products.slack_app.backend.services.slack_app_home.is_slack_workspace_admin", return_value=False),- ):+ with patch("products.slack_app.backend.services.slack_app_home.is_slack_workspace_admin", return_value=False):handle_ai_preferences_block_action(payload, payload["actions"][0])row = SlackSettings.objects.filter(slack_workspace_id=SLACK_WORKSPACE_ID, slack_user_id="U001").first()