: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
feat(tasks): let the task profile turn off pull requests (#125255)
Charles Vien62ee32e66180
diff --git a/products/business_knowledge/backend/sandbox.py b/products/business_knowledge/backend/sandbox.pyindex 62de86db7db4..c75ec28fce8b 100644--- a/products/business_knowledge/backend/sandbox.py+++ b/products/business_knowledge/backend/sandbox.py@@ -269,7 +269,6 @@ def start_sandbox_run(description=build_sandbox_prompt(question, always_on, repo_tools=repository_tools_enabled(team)),profile=task_profiles.BUSINESS_KNOWLEDGE,user_id=user_id,- create_pr=False,sandbox_environment_id=str(env_id),options=TaskRunOptions(model=SANDBOX_MODEL,diff --git a/products/business_knowledge/backend/task_profiles.py b/products/business_knowledge/backend/task_profiles.pyindex ccd948b7eafc..794f3e1a65fa 100644--- a/products/business_knowledge/backend/task_profiles.py+++ b/products/business_knowledge/backend/task_profiles.py@@ -35,6 +35,7 @@ BUSINESS_KNOWLEDGE = TaskProfile(github_resolution=GithubResolution.ALWAYS,user_authorable_prs=False,default_pr_authorship=PrAuthorship.BOT,+ create_pr=False,finish_tool=False,done_on_turn_close=False,idle_minutes=30,diff --git a/products/tasks/backend/facade/profiles.py b/products/tasks/backend/facade/profiles.pyindex 2d0eed1c67fd..aafdd300ffb4 100644--- a/products/tasks/backend/facade/profiles.py+++ b/products/tasks/backend/facade/profiles.py@@ -161,6 +161,9 @@ class TaskProfile:user_authorable_prs: bool# Who authors pull requests when the run does not set TaskRunOptions.pr_authorship_mode.default_pr_authorship: PrAuthorship+ # True lets a run open a pull request when it finishes. A caller can still turn it off for one+ # run. False means runs never open one, whatever the caller passes.+ create_pr: bool# True gives the agent a finish tool that moves the task to done.finish_tool: bool# True moves the task to done when a turn closes, including a failed turn. Use it for work thatdiff --git a/products/tasks/backend/temporal/process_task/activities/get_task_processing_context.py b/products/tasks/backend/temporal/process_task/activities/get_task_processing_context.pyindex 2532126f68d4..59d92b4fb4e2 100644--- a/products/tasks/backend/temporal/process_task/activities/get_task_processing_context.py+++ b/products/tasks/backend/temporal/process_task/activities/get_task_processing_context.py@@ -1321,7 +1321,7 @@ def get_task_processing_context(input: GetTaskProcessingContextInput) -> TaskProtask_runtime=task.runtime,environment=task_run.environment,task_created_by_id=task.created_by_id,- create_pr=input.create_pr,+ create_pr=input.create_pr and (profile is None or profile.create_pr),pr_loop_enabled=pr_loop_enabled,pr_babysit_enabled=pr_loop_enabled,context_layer_enabled=context_layer_enabled,diff --git a/products/tasks/backend/temporal/process_task/activities/tests/test_get_task_processing_context.py b/products/tasks/backend/temporal/process_task/activities/tests/test_get_task_processing_context.pyindex 2a92031aa320..fdf5e4727187 100644--- a/products/tasks/backend/temporal/process_task/activities/tests/test_get_task_processing_context.py+++ b/products/tasks/backend/temporal/process_task/activities/tests/test_get_task_processing_context.py@@ -446,6 +446,30 @@ class TestGetTaskProcessingContextActivity:finally:self._cleanup_task(task)+ @pytest.mark.django_db(transaction=True)+ @pytest.mark.parametrize(+ "stored_profile,requested,expected",+ [+ (None, True, True),+ (None, False, False),+ ("business_knowledge", True, False),+ ("business_knowledge", False, False),+ ("test.unregistered", True, True),+ ],+ )+ def test_get_task_processing_context_lets_the_profile_turn_off_create_pr(+ self, activity_environment, test_task, stored_profile, requested, expected+ ):+ test_task.profile = stored_profile+ test_task.save(update_fields=["profile"])+ task_run = test_task.create_run()++ result = async_to_sync(activity_environment.run)(+ get_task_processing_context, GetTaskProcessingContextInput(run_id=str(task_run.id), create_pr=requested)+ )++ assert result.create_pr is expected+@pytest.mark.django_db(transaction=True)@pytest.mark.parametrize("stored_profile,expected_profile",