: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): keep live context off on knowledge writer runs (#126648)
John C. Waters73cbc682977d
diff --git a/products/tasks/backend/models.py b/products/tasks/backend/models.pyindex 65455e58e871..1cdbbe092fb8 100644--- a/products/tasks/backend/models.py+++ b/products/tasks/backend/models.py@@ -962,6 +962,8 @@ class Task(Taggable, DeletedMetaFields, models.Model):state["sandbox_template"] = previous_state["sandbox_template"]elif carry_sandbox_template and (stored_profile := task.stored_profile) is not None:state["sandbox_template"] = stored_profile.sandbox_templates[0]+ if task.origin_product == Task.OriginProduct.KNOWLEDGE_WRITER:+ state["include_live_context"] = Falseif task._resolves_pr_authorship_per_run() and "pr_authorship_mode" not in state:from products.tasks.backend.temporal.process_task.utils import (PrAuthorshipMode,diff --git a/products/tasks/backend/tests/test_models.py b/products/tasks/backend/tests/test_models.pyindex 290cc5f0cc1b..46109d10ccc1 100644--- a/products/tasks/backend/tests/test_models.py+++ b/products/tasks/backend/tests/test_models.py@@ -833,6 +833,20 @@ class TestTask(TestCase):self.assertNotIn("ai_stage", run.state)+ def test_create_run_turns_live_context_off_on_every_knowledge_writer_run(self):+ task = Task.objects.create(+ team=self.team,+ title="Docs for a merged PR",+ description="Writer",+ origin_product=Task.OriginProduct.KNOWLEDGE_WRITER,+ )++ first_run = task.create_run(extra_state={"include_live_context": True})+ later_run = task.create_run(mode="background")++ self.assertIs(first_run.state["include_live_context"], False)+ self.assertIs(later_run.state["include_live_context"], False)+def test_create_run_keeps_the_pipeline_stage_over_the_interactive_stamp(self):from products.signals.backend.models import SignalReport