: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(business-knowledge): create tasks from the task profile (#125250)
Charles Viene6d4cb42f70b
diff --git a/products/business_knowledge/backend/sandbox.py b/products/business_knowledge/backend/sandbox.pyindex 6be525a80000..62de86db7db4 100644--- a/products/business_knowledge/backend/sandbox.py+++ b/products/business_knowledge/backend/sandbox.py@@ -16,7 +16,9 @@ from posthog.models.team.team import Teamfrom products.tasks.backend.facade import api as tasks_facadefrom products.tasks.backend.facade.contracts import CreatedTaskDTO, TaskRunDTO+from products.tasks.backend.facade.profiles import TaskRunOptions+from . import task_profilesfrom .constants import BK_MCP_SCOPESfrom .github_repos import repository_tools_enabledfrom .logic import KnowledgeSearchResult, get_always_on_context@@ -246,7 +248,6 @@ def start_sandbox_run(its own lock. The default allows one open run per person. `on_admitted` runs in the sametransaction, so a playground turn is stored with the task or not at all."""- origin = tasks_facade.TaskOriginProduct.BUSINESS_KNOWLEDGEwith transaction.atomic():if admit is None:_admit_one_run_per_owner(team.id, user_id)@@ -266,16 +267,16 @@ def start_sandbox_run(team=team,title=_title_for(question),description=build_sandbox_prompt(question, always_on, repo_tools=repository_tools_enabled(team)),- origin_product=origin,+ profile=task_profiles.BUSINESS_KNOWLEDGE,user_id=user_id,- repository=None,create_pr=False,- internal=True,sandbox_environment_id=str(env_id),- posthog_mcp_scopes=BK_MCP_SCOPES,- model=SANDBOX_MODEL,- runtime_adapter=SANDBOX_RUNTIME_ADAPTER,- output_schema=SandboxAnswer,+ options=TaskRunOptions(+ model=SANDBOX_MODEL,+ adapter=SANDBOX_RUNTIME_ADAPTER,+ mcp_scopes=BK_MCP_SCOPES,+ output_schema=SandboxAnswer.model_json_schema(),+ ),extra_run_state={"mcp_exclude_tools": BK_HIDDEN_TOOLS,"config_snapshot": {"connectors": {"mcp_installation_ids": []}},diff --git a/products/business_knowledge/backend/tests/test_sandbox.py b/products/business_knowledge/backend/tests/test_sandbox.pyindex c94ef5c1835c..e671d4a6b677 100644--- a/products/business_knowledge/backend/tests/test_sandbox.py+++ b/products/business_knowledge/backend/tests/test_sandbox.py@@ -233,6 +233,7 @@ class TestSandboxAPI(APIBaseTest):task = Task.objects.get(id=body["task_id"])run = TaskRun.objects.get(id=body["run_id"])assert task.origin_product == Task.OriginProduct.BUSINESS_KNOWLEDGE+ assert task.profile == "business_knowledge"assert task.internal is Trueassert task.repository is Noneassert task.created_by_id == self.user.id