: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
fix(tasks): route stageless signals sandbox runs to the go gateway (#124795)
Jonathan Mieloo47f64f0f9053
diff --git a/products/tasks/backend/models.py b/products/tasks/backend/models.pyindex 1cdbbe092fb8..5352b5e77494 100644--- a/products/tasks/backend/models.py+++ b/products/tasks/backend/models.py@@ -129,6 +129,7 @@ PRIOR_RUN_TAGS_STATE_KEY = "prior_run_tags"# Stage `Task.create_run` stamps on a person-started signals run, so it resolves a mintable# gateway product. Keyed by origin value.INTERACTIVE_SIGNALS_AI_STAGE_BY_ORIGIN: dict[str, str] = {"signal_report": "inbox", "signals_chat": "chat"}+INTERNAL_SIGNALS_AI_STAGE_BY_ORIGIN: dict[str, str] = {"scout_suggestions": "scout_suggestions"}MCP_BUILT_IN_AGENT_KEY_BY_ORIGIN: dict[str, MCPBuiltInAgentKey] = {"support_reply": "support",@@ -996,6 +997,9 @@ class Task(Taggable, DeletedMetaFields, models.Model):if interactive_stage and not state.get("ai_stage") and not task.internal:if task.origin_product != Task.OriginProduct.SIGNAL_REPORT or task.signal_report_id:state["ai_stage"] = interactive_stage+ internal_stage = INTERNAL_SIGNALS_AI_STAGE_BY_ORIGIN.get(task.origin_product)+ if internal_stage and not state.get("ai_stage") and task.internal:+ state["ai_stage"] = internal_stage# A manual resume can share an internal Task with an automated run. Freeze billing# on this run so historical PR charges and pipeline attribution do not change.diff --git a/products/tasks/backend/tests/test_models.py b/products/tasks/backend/tests/test_models.pyindex 46109d10ccc1..1a33d36be394 100644--- a/products/tasks/backend/tests/test_models.py+++ b/products/tasks/backend/tests/test_models.py@@ -882,17 +882,30 @@ class TestTask(TestCase):self.assertNotIn("ai_stage", run.state)- def test_create_run_stamps_chat_on_a_signals_chat_task(self):+ @parameterized.expand(+ [+ ("signals_chat", Task.OriginProduct.SIGNALS_CHAT, False, "interactive", "chat"),+ (+ "internal_scout_suggestions",+ Task.OriginProduct.SIGNALS_SCOUT_SUGGESTIONS,+ True,+ "background",+ "scout_suggestions",+ ),+ ]+ )+ def test_create_run_stamps_the_signals_stage_for_its_origin(self, _name, origin_product, internal, mode, stage):task = Task.objects.create(team=self.team,- title="Suggest a scout",- description="Chat",- origin_product=Task.OriginProduct.SIGNALS_CHAT,+ title="Signals task",+ description="Stageless run",+ origin_product=origin_product,+ internal=internal,)- run = task.create_run(mode="interactive")+ run = task.create_run(mode=mode)- self.assertEqual(run.state["ai_stage"], "chat")+ self.assertEqual(run.state["ai_stage"], stage)@patch("products.tasks.backend.temporal.client.execute_task_processing_workflow")def test_create_and_run_omits_permission_mode_when_not_provided(self, mock_execute_workflow):